前回までに分布特性を把握するためのいくつかの指標を説明し、 その使い方や注意点を喚起した。 今回は、単純集計としてよく利用される頻度集計(クロス集計)の方法を紹介する。
/* Lesson 08-1 */ /* File Name = les0801.sas 11/25/04 */ data gakusei; infile 'all04b.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 11:13 Wednesday, November 24, 2004 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 11:13 Wednesday, November 24, 2004 Cumulative Cumulative SEX Frequency Percent Frequency Percent ------------------------------------------------- F 108 34.5 108 34.5 M 205 65.5 313 100.0 Frequency Missing = 4 Cumulative Cumulative JITAKU Frequency Percent Frequency Percent ---------------------------------------------------- G 103 37.2 103 37.2 J 174 62.8 277 100.0 Frequency Missing = 40 Cumulative Cumulative CARRYER Frequency Percent Frequency Percent ------------------------------------------------------ DDIp 2 2.1 2 2.1 DoCoMo 45 46.9 47 49.0 J-PHONE 10 10.4 57 59.4 No 4 4.2 61 63.5 Vodafone 13 13.5 74 77.1 au 22 22.9 96 100.0 Frequency Missing = 221 SAS システム 4 11:13 Wednesday, November 24, 2004 TABLE OF SEX BY JITAKU SEX JITAKU Frequency| Percent | Row Pct | Col Pct |G |J | Total ---------+--------+--------+ F | 31 | 65 | 96 | 11.27 | 23.64 | 34.91 | 32.29 | 67.71 | | 30.39 | 37.57 | ---------+--------+--------+ M | 71 | 108 | 179 | 25.82 | 39.27 | 65.09 | 39.66 | 60.34 | | 69.61 | 62.43 | ---------+--------+--------+ Total 102 173 275 37.09 62.91 100.00 Frequency Missing = 42 SAS システム 7 11:13 Wednesday, November 24, 2004 TABLE OF SEX BY CARRYER SEX CARRYER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |J-PHONE |No |Vodafone|au | Total ---------+--------+--------+--------+--------+--------+--------+ F | 1 | 20 | 4 | 1 | 8 | 9 | 43 | 1.05 | 21.05 | 4.21 | 1.05 | 8.42 | 9.47 | 45.26 | 2.33 | 46.51 | 9.30 | 2.33 | 18.60 | 20.93 | | 50.00 | 44.44 | 44.44 | 25.00 | 61.54 | 40.91 | ---------+--------+--------+--------+--------+--------+--------+ M | 1 | 25 | 5 | 3 | 5 | 13 | 52 | 1.05 | 26.32 | 5.26 | 3.16 | 5.26 | 13.68 | 54.74 | 1.92 | 48.08 | 9.62 | 5.77 | 9.62 | 25.00 | | 50.00 | 55.56 | 55.56 | 75.00 | 38.46 | 59.09 | ---------+--------+--------+--------+--------+--------+--------+ Total 2 45 9 4 13 22 95 2.11 47.37 9.47 4.21 13.68 23.16 100.00 Frequency Missing = 222 SAS システム 10 11:13 Wednesday, November 24, 2004 TABLE OF JITAKU BY CARRYER JITAKU CARRYER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |J-PHONE |No |Vodafone|au | Total ---------+--------+--------+--------+--------+--------+--------+ G | 1 | 17 | 4 | 0 | 4 | 6 | 32 | 1.18 | 20.00 | 4.71 | 0.00 | 4.71 | 7.06 | 37.65 | 3.13 | 53.13 | 12.50 | 0.00 | 12.50 | 18.75 | | 100.00 | 42.50 | 44.44 | 0.00 | 33.33 | 30.00 | ---------+--------+--------+--------+--------+--------+--------+ J | 0 | 23 | 5 | 3 | 8 | 14 | 53 | 0.00 | 27.06 | 5.88 | 3.53 | 9.41 | 16.47 | 62.35 | 0.00 | 43.40 | 9.43 | 5.66 | 15.09 | 26.42 | | 0.00 | 57.50 | 55.56 | 100.00 | 66.67 | 70.00 | ---------+--------+--------+--------+--------+--------+--------+ Total 1 40 9 3 12 20 85 1.18 47.06 10.59 3.53 14.12 23.53 100.00 Frequency Missing = 232
/* Lesson 08-4 */ /* File Name = les0804.sas 11/25/04 */ data gakusei; infile 'all04b.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 11:14 Wednesday, November 24, 2004 Cumulative Cumulative SHINTYOU Frequency Percent Frequency Percent ------------------------------------------------------ -149 6 2.0 6 2.0 150-159 44 14.5 50 16.5 160-169 107 35.3 157 51.8 170-179 126 41.6 283 93.4 180- 20 6.6 303 100.0 Frequency Missing = 14 SAS システム 3 11:14 Wednesday, November 24, 2004 TABLE OF SEX BY SHINTYOU SEX SHINTYOU Frequency| Percent | Row Pct | Col Pct | -149 |150-159 |160-169 |170-179 |180- | Total ---------+--------+--------+--------+--------+--------+ F | 6 | 43 | 50 | 2 | 0 | 101 | 1.99 | 14.24 | 16.56 | 0.66 | 0.00 | 33.44 | 5.94 | 42.57 | 49.50 | 1.98 | 0.00 | | 100.00 | 97.73 | 47.17 | 1.59 | 0.00 | ---------+--------+--------+--------+--------+--------+ M | 0 | 1 | 56 | 124 | 20 | 201 | 0.00 | 0.33 | 18.54 | 41.06 | 6.62 | 66.56 | 0.00 | 0.50 | 27.86 | 61.69 | 9.95 | | 0.00 | 2.27 | 52.83 | 98.41 | 100.00 | ---------+--------+--------+--------+--------+--------+ Total 6 44 106 126 20 302 1.99 14.57 35.10 41.72 6.62 100.00 Frequency Missing = 15 SAS システム 6 11:14 Wednesday, November 24, 2004 ------------------------------- SEX=' ' -------------------------------- Cumulative Cumulative SHINTYOU Frequency Percent Frequency Percent ------------------------------------------------------ 160-169 1 100.0 1 100.0 Frequency Missing = 3 SAS システム 7 11:14 Wednesday, November 24, 2004 -------------------------------- SEX=F --------------------------------- Cumulative Cumulative SHINTYOU Frequency Percent Frequency Percent ------------------------------------------------------ -149 6 5.9 6 5.9 150-159 43 42.6 49 48.5 160-169 50 49.5 99 98.0 170-179 2 2.0 101 100.0 Frequency Missing = 7 SAS システム 8 11:14 Wednesday, November 24, 2004 -------------------------------- SEX=M --------------------------------- Cumulative Cumulative SHINTYOU Frequency Percent Frequency Percent ------------------------------------------------------ 150-159 1 0.5 1 0.5 160-169 56 27.9 57 28.4 170-179 124 61.7 181 90.0 180- 20 10.0 201 100.0 Frequency Missing = 4
/* Lesson 08-5 */ /* File Name = les0805.sas 11/25/04 */ data gakusei; infile 'all04b.prn' firstobs=2; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carryer $ tsuuwa; proc format; value clshint low-<150=' -149' 150-<160='150-159' 160-<170='160-169' 170-<180='170-179' 180-high='180- ' other ='missing'; run; proc print data=gakusei(obs=5); run; proc tabulate data=gakusei; : 要約統計量の表の作成 class sex jitaku; : 特性変数であることの宣言 var kodukai; : 集計する変量名 tables kodukai*(n mean std),sex*jitaku; : 表示内容、分類変量名 run; : proc tabulate data=gakusei; : class shintyou sex; : var taijyuu; : tables taijyuu*(n mean std),shintyou*sex; : format shintyou clshint.; : 連続変量をグループ化することの指定 run; :
SAS システム 2 11:14 Wednesday, November 24, 2004 ---------------------------------------------------------------------- | | SEX | | |---------------------------------------------------| | | F | M | | |-------------------------+-------------------------| | | JITAKU | JITAKU | | |-------------------------+-------------------------| | | G | J | G | J | |----------------+------------+------------+------------+------------| |KODUKAI|N | 29.00| 63.00| 70.00| 105.00| | |--------+------------+------------+------------+------------| | |MEAN | 81379.31| 35198.41| 83900.00| 26552.38| | |--------+------------+------------+------------+------------| | |STD | 62233.67| 31042.57| 53760.65| 35593.32| ---------------------------------------------------------------------- SAS システム 3 11:14 Wednesday, November 24, 2004 ---------------------------------------------------------------------- | | SHINTYOU | | |---------------------------------------------------| | | -149 | 150-159 | 160-169 | | |------------+-------------------------+------------| | | SEX | SEX | SEX | | |------------+-------------------------+------------| | | F | F | M | F | |----------------+------------+------------+------------+------------| |TAIJYUU|N | 5.00| 33.00| 1.00| 32.00| | |--------+------------+------------+------------+------------| | |MEAN | 41.80| 46.98| 61.00| 51.18| | |--------+------------+------------+------------+------------| | |STD | 2.59| 4.49| .| 3.54| ---------------------------------------------------------------------- (CONTINUED) SAS システム 4 11:14 Wednesday, November 24, 2004 ---------------------------------------------------------------------- | | SHINTYOU | | |---------------------------------------------------| | | 160-169 | 170-179 | 180- | | |------------+-------------------------+------------| | | SEX | SEX | SEX | | |------------+-------------------------+------------| | | M | F | M | M | |----------------+------------+------------+------------+------------| |TAIJYUU|N | 56.00| 0.00| 124.00| 20.00| | |--------+------------+------------+------------+------------| | |MEAN | 58.74| .| 62.98| 67.58| | |--------+------------+------------+------------+------------| | |STD | 7.78| .| 7.48| 7.95| ----------------------------------------------------------------------
data gakusei; infile 'all04b.prn' firstobs=2; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carryer $ tsuuwa; dekasa=shintyou+taijyuu+kyoui; : 変量間の加減乗除 kyo_2=kyoui**2; : 二乗 kyo_sr=sqrt(kyoui); : ルート
[算術演算子]
[数値関数]