前回までに分布特性を把握するためのいくつかの指標を説明し、 その使い方や注意点を喚起した。 今回は、単純集計としてよく利用される頻度集計やクロス集計の方法を紹介する。
iv. 統計関連
/* Lesson 08-1 */
/* File Name = les0801.sas 06/08/06 */
data gakusei;
infile 'all06ae.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
proc print data=gakusei(obs=5);
run;
:
proc freq data=gakusei; : 頻度を算出
tables sex jitaku carryer; : 一変量ごとに
run; :
proc freq data=gakusei; : 頻度を算出
tables sex*jitaku; : 二変量の組み合わせで
tables sex*carryer; :
tables jitaku*carryer; :
run; :
SAS システム 1
09:02 Thursday, June 8, 2006
OBS SEX SHINTYOU TAIJYUU KYOUI JITAKU KODUKAI CARRYER TSUUWA
1 F 145.0 38 . J 10000 .
2 F 146.7 41 85 J 10000 Vodafone 6000
3 F 148.0 42 . J 50000 .
4 F 148.0 43 80 J 50000 DoCoMo 4000
5 F 148.9 . . J 60000 .
SAS システム 2
09:02 Thursday, June 8, 2006
Cumulative Cumulative
SEX Frequency Percent Frequency Percent
-------------------------------------------------
F 117 33.5 117 33.5
M 232 66.5 349 100.0
Frequency Missing = 5
Cumulative Cumulative
JITAKU Frequency Percent Frequency Percent
----------------------------------------------------
G 110 36.4 110 36.4
J 192 63.6 302 100.0
Frequency Missing = 52
Cumulative Cumulative
CARRYER Frequency Percent Frequency Percent
------------------------------------------------------
DDIp 2 1.5 2 1.5
DoCoMo 56 43.1 58 44.6
J-PHONE 10 7.7 68 52.3
KDDI 1 0.8 69 53.1
No 5 3.8 74 56.9
Vodafone 20 15.4 94 72.3
Willcom 1 0.8 95 73.1
au 35 26.9 130 100.0
Frequency Missing = 224
SAS システム 5
09:02 Thursday, June 8, 2006
TABLE OF SEX BY JITAKU
SEX JITAKU
Frequency|
Percent |
Row Pct |
Col Pct |G |J | Total
---------+--------+--------+
F | 34 | 66 | 100
| 11.33 | 22.00 | 33.33
| 34.00 | 66.00 |
| 31.19 | 34.55 |
---------+--------+--------+
M | 75 | 125 | 200
| 25.00 | 41.67 | 66.67
| 37.50 | 62.50 |
| 68.81 | 65.45 |
---------+--------+--------+
Total 109 191 300
36.33 63.67 100.00
Frequency Missing = 54
SAS システム 8
09:02 Thursday, June 8, 2006
TABLE OF SEX BY CARRYER
SEX CARRYER
Frequency|
Percent |
Row Pct |
Col Pct |DDIp |DoCoMo |J-PHONE |KDDI | Total
---------+--------+--------+--------+--------+
F | 1 | 23 | 4 | 0 | 51
| 0.78 | 17.83 | 3.10 | 0.00 | 39.53
| 1.96 | 45.10 | 7.84 | 0.00 |
| 50.00 | 41.07 | 44.44 | 0.00 |
---------+--------+--------+--------+--------+
M | 1 | 33 | 5 | 1 | 78
| 0.78 | 25.58 | 3.88 | 0.78 | 60.47
| 1.28 | 42.31 | 6.41 | 1.28 |
| 50.00 | 58.93 | 55.56 | 100.00 |
---------+--------+--------+--------+--------+
Total 2 56 9 1 129
1.55 43.41 6.98 0.78 100.00
(Continued)
SAS システム 10
09:02 Thursday, June 8, 2006
TABLE OF SEX BY CARRYER
SEX CARRYER
Frequency|
Percent |
Row Pct |
Col Pct |No |Vodafone|Willcom |au | Total
---------+--------+--------+--------+--------+
F | 1 | 9 | 1 | 12 | 51
| 0.78 | 6.98 | 0.78 | 9.30 | 39.53
| 1.96 | 17.65 | 1.96 | 23.53 |
| 20.00 | 45.00 | 100.00 | 34.29 |
---------+--------+--------+--------+--------+
M | 4 | 11 | 0 | 23 | 78
| 3.10 | 8.53 | 0.00 | 17.83 | 60.47
| 5.13 | 14.10 | 0.00 | 29.49 |
| 80.00 | 55.00 | 0.00 | 65.71 |
---------+--------+--------+--------+--------+
Total 5 20 1 35 129
3.88 15.50 0.78 27.13 100.00
Frequency Missing = 225
≪前略≫
proc freq data=gakusei order=freq; : 頻度の高いもの順
tables sex jitaku carryer; :
run; :
:
proc freq data=gakusei order=freq; : 頻度の高いもの順
tables sex*jitaku; :
tables sex*carryer; :
tables jitaku*carryer; :
run; :
≪後略≫
/* Lesson 08-4 */
/* File Name = les0804.sas 06/08/06 */
data gakusei;
infile 'all06ae.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
proc format; : 階級を作る。class shintyou の意
value clshint low-<150=' -149' : 階級の定義 1
150-<160='150-159' : 2
160-<170='160-169' : 3
170-<180='170-179' : 4
180-high='180- ' : 5
other ='missing'; : 6
run; :
proc print data=gakusei(obs=5);
run;
proc freq data=gakusei; : 頻度を算出
tables shintyou; : 一変量ごとに
format shintyou clshint.; : 連続変量をグループ化することの指定
run; :
:
proc freq data=gakusei; : 頻度を算出
tables sex*shintyou; : 二変量の組合わせで
format shintyou clshint.; : 連続変量をグループ化することの指定
run; :
:
proc sort data=gakusei; : 今までの方法で実現しようとすると
by sex; :
run; :
proc freq data=gakusei; :
tables shintyou; :
format shintyou clshint.; : 連続変量をグループ化することの指定
by sex; : 性別ごとに
run; :
SAS システム 2
09:02 Thursday, June 8, 2006
Cumulative Cumulative
SHINTYOU Frequency Percent Frequency Percent
------------------------------------------------------
-149 6 1.8 6 1.8
150-159 50 14.7 56 16.5
160-169 116 34.2 172 50.7
170-179 144 42.5 316 93.2
180- 23 6.8 339 100.0
Frequency Missing = 15
SAS システム 3
09:02 Thursday, June 8, 2006
TABLE OF SEX BY SHINTYOU
SEX SHINTYOU
Frequency|
Percent |
Row Pct |
Col Pct | -149 |150-159 |160-169 |170-179 |180- | Total
---------+--------+--------+--------+--------+--------+
F | 6 | 48 | 54 | 2 | 0 | 110
| 1.78 | 14.20 | 15.98 | 0.59 | 0.00 | 32.54
| 5.45 | 43.64 | 49.09 | 1.82 | 0.00 |
| 100.00 | 96.00 | 46.96 | 1.39 | 0.00 |
---------+--------+--------+--------+--------+--------+
M | 0 | 2 | 61 | 142 | 23 | 228
| 0.00 | 0.59 | 18.05 | 42.01 | 6.80 | 67.46
| 0.00 | 0.88 | 26.75 | 62.28 | 10.09 |
| 0.00 | 4.00 | 53.04 | 98.61 | 100.00 |
---------+--------+--------+--------+--------+--------+
Total 6 50 115 144 23 338
1.78 14.79 34.02 42.60 6.80 100.00
Frequency Missing = 16
SAS システム 6
09:02 Thursday, June 8, 2006
------------------------------- SEX=' ' --------------------------------
Cumulative Cumulative
SHINTYOU Frequency Percent Frequency Percent
------------------------------------------------------
160-169 1 100.0 1 100.0
Frequency Missing = 4
SAS システム 7
09:02 Thursday, June 8, 2006
-------------------------------- SEX=F ---------------------------------
Cumulative Cumulative
SHINTYOU Frequency Percent Frequency Percent
------------------------------------------------------
-149 6 5.5 6 5.5
150-159 48 43.6 54 49.1
160-169 54 49.1 108 98.2
170-179 2 1.8 110 100.0
Frequency Missing = 7
SAS システム 8
09:02 Thursday, June 8, 2006
-------------------------------- SEX=M ---------------------------------
Cumulative Cumulative
SHINTYOU Frequency Percent Frequency Percent
------------------------------------------------------
150-159 2 0.9 2 0.9
160-169 61 26.8 63 27.6
170-179 142 62.3 205 89.9
180- 23 10.1 228 100.0
Frequency Missing = 4