/* Lesson 06-1 */ /* File Name = les0601.sas 11/13/03 */ data gakusei; : infile 'all03b.prn' firstobs=2; : 2行目からをデータとして読み込む input sex $ height weight chest : jitaku $ kodukai carrier $ tsuuwa; : : proc print data=gakusei(obs=10); : きちんと読み込めたか確認のため run; : : proc freq data=gakusei; : 頻度を算出 tables sex jitaku carrier; : 一変量ごとに run; : proc freq data=gakusei; : 頻度を算出 tables sex*jitaku; : 二変量の組み合わせで tables sex*carrier; : tables jitaku*carrier; : run; :
SAS システム 1 11:23 Wednesday, November 12, 2003 OBS SEX HEIGHT WEIGHT CHEST JITAKU KODUKAI CARRIER TSUUWA 1 F 145.0 38.0 . J 10000 . 2 F 148.0 42.0 . J 50000 . 3 F 148.0 43.0 80 J 50000 DoCoMo 4000 4 F 148.9 . . J 60000 . 5 F 149.0 45.0 . G 60000 . 6 F 150.0 46.0 86 40000 . 7 F 151.0 50.0 . G 60000 J-PHONE . 8 F 151.7 41.5 80 J 35000 . 9 F 152.0 35.0 77 J 60000 DoCoMo 2000 10 F 153.0 41.0 . J 125000 No . SAS システム 2 11:23 Wednesday, November 12, 2003 Cumulative Cumulative SEX Frequency Percent Frequency Percent ------------------------------------------------- F 85 32.4 85 32.4 M 177 67.6 262 100.0 Frequency Missing = 3 Cumulative Cumulative JITAKU Frequency Percent Frequency Percent ---------------------------------------------------- G 86 37.1 86 37.1 J 146 62.9 232 100.0 Frequency Missing = 33 Cumulative Cumulative CARRIER Frequency Percent Frequency Percent ------------------------------------------------------ DDIp 2 4.0 2 4.0 DoCoMo 25 50.0 27 54.0 J-PHONE 10 20.0 37 74.0 No 3 6.0 40 80.0 Vodafone 2 4.0 42 84.0 au 8 16.0 50 100.0 Frequency Missing = 215 SAS システム 4 11:23 Wednesday, November 12, 2003 TABLE OF SEX BY JITAKU SEX JITAKU Frequency| Percent | Row Pct | Col Pct |G |J | Total ---------+--------+--------+ F | 25 | 50 | 75 | 10.87 | 21.74 | 32.61 | 33.33 | 66.67 | | 29.41 | 34.48 | ---------+--------+--------+ M | 60 | 95 | 155 | 26.09 | 41.30 | 67.39 | 38.71 | 61.29 | | 70.59 | 65.52 | ---------+--------+--------+ Total 85 145 230 36.96 63.04 100.00 Frequency Missing = 35 SAS システム 7 11:23 Wednesday, November 12, 2003 TABLE OF SEX BY CARRIER SEX CARRIER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |J-PHONE |No |Vodafone|au | Total ---------+--------+--------+--------+--------+--------+--------+ F | 1 | 12 | 4 | 1 | 1 | 2 | 21 | 2.04 | 24.49 | 8.16 | 2.04 | 2.04 | 4.08 | 42.86 | 4.76 | 57.14 | 19.05 | 4.76 | 4.76 | 9.52 | | 50.00 | 48.00 | 44.44 | 33.33 | 50.00 | 25.00 | ---------+--------+--------+--------+--------+--------+--------+ M | 1 | 13 | 5 | 2 | 1 | 6 | 28 | 2.04 | 26.53 | 10.20 | 4.08 | 2.04 | 12.24 | 57.14 | 3.57 | 46.43 | 17.86 | 7.14 | 3.57 | 21.43 | | 50.00 | 52.00 | 55.56 | 66.67 | 50.00 | 75.00 | ---------+--------+--------+--------+--------+--------+--------+ Total 2 25 9 3 2 8 49 4.08 51.02 18.37 6.12 4.08 16.33 100.00 Frequency Missing = 216 SAS システム 10 11:23 Wednesday, November 12, 2003 TABLE OF JITAKU BY CARRIER JITAKU CARRIER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |J-PHONE |No |Vodafone|au | Total ---------+--------+--------+--------+--------+--------+--------+ G | 1 | 10 | 4 | 0 | 0 | 4 | 19 | 2.22 | 22.22 | 8.89 | 0.00 | 0.00 | 8.89 | 42.22 | 5.26 | 52.63 | 21.05 | 0.00 | 0.00 | 21.05 | | 100.00 | 43.48 | 44.44 | 0.00 | 0.00 | 50.00 | ---------+--------+--------+--------+--------+--------+--------+ J | 0 | 13 | 5 | 3 | 1 | 4 | 26 | 0.00 | 28.89 | 11.11 | 6.67 | 2.22 | 8.89 | 57.78 | 0.00 | 50.00 | 19.23 | 11.54 | 3.85 | 15.38 | | 0.00 | 56.52 | 55.56 | 100.00 | 100.00 | 50.00 | ---------+--------+--------+--------+--------+--------+--------+ Total 1 23 9 3 1 8 45 2.22 51.11 20.00 6.67 2.22 17.78 100.00 Frequency Missing = 220
/* Lesson 06-2 */ /* File Name = les0602.sas 11/13/03 */ data gakusei; infile 'all03b.prn' firstobs=2; input sex $ height weight chest jitaku $ kodukai carrier $ tsuuwa; proc format; : 階級を作る。class height の意 value clheight 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=10); run; proc chart data=gakusei; : hvar height / midpoints=145 to 185 by 10; : 比較のための水平棒グラフ run; : proc freq data=gakusei; : 頻度を算出 tables height; : 一変量ごとに format height clheight.; : 連続変量をグループ化することの指定 run; : : proc freq data=gakusei; : 頻度を算出 tables sex*height; : 二変量の組合わせで format height clheight.; : 連続変量をグループ化することの指定 run; : : proc sort data=gakusei; : 今までの方法で実現しようとすると by sex; : run; : proc freq data=gakusei; : tables height; : format height clheight.; : 連続変量をグループ化することの指定 by sex; : 性別ごとに run; :
SAS システム 2 12:07 Wednesday, November 12, 2003 HEIGHT Cum. Cum. Midpoint Freq Freq Percent Percent | 145 |* 5 5 1.96 1.96 | 155 |******* 34 39 13.33 15.29 | 165 |****************** 90 129 35.29 50.59 | 175 |********************** 108 237 42.35 92.94 | 185 |**** 18 255 7.06 100.00 | ----+---+---+---+---+-- 20 40 60 80 100 Frequency SAS システム 3 12:07 Wednesday, November 12, 2003 Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- -149 5 2.0 5 2.0 150-159 34 13.3 39 15.3 160-169 90 35.3 129 50.6 170-179 108 42.4 237 92.9 180- 18 7.1 255 100.0 Frequency Missing = 10 SAS システム 4 12:07 Wednesday, November 12, 2003 TABLE OF SEX BY HEIGHT SEX HEIGHT Frequency| Percent | Row Pct | Col Pct | -149 |150-159 |160-169 |170-179 |180- | Total ---------+--------+--------+--------+--------+--------+ F | 5 | 33 | 41 | 2 | 0 | 81 | 1.97 | 12.99 | 16.14 | 0.79 | 0.00 | 31.89 | 6.17 | 40.74 | 50.62 | 2.47 | 0.00 | | 100.00 | 97.06 | 46.07 | 1.85 | 0.00 | ---------+--------+--------+--------+--------+--------+ M | 0 | 1 | 48 | 106 | 18 | 173 | 0.00 | 0.39 | 18.90 | 41.73 | 7.09 | 68.11 | 0.00 | 0.58 | 27.75 | 61.27 | 10.40 | | 0.00 | 2.94 | 53.93 | 98.15 | 100.00 | ---------+--------+--------+--------+--------+--------+ Total 5 34 89 108 18 254 1.97 13.39 35.04 42.52 7.09 100.00 Frequency Missing = 11 SAS システム 7 12:07 Wednesday, November 12, 2003 ------------------------------- SEX=' ' -------------------------------- Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- 160-169 1 100.0 1 100.0 Frequency Missing = 2 SAS システム 8 12:07 Wednesday, November 12, 2003 -------------------------------- SEX=F --------------------------------- Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- -149 5 6.2 5 6.2 150-159 33 40.7 38 46.9 160-169 41 50.6 79 97.5 170-179 2 2.5 81 100.0 Frequency Missing = 4 SAS システム 9 12:07 Wednesday, November 12, 2003 -------------------------------- SEX=M --------------------------------- Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- 150-159 1 0.6 1 0.6 160-169 48 27.7 49 28.3 170-179 106 61.3 155 89.6 180- 18 10.4 173 100.0 Frequency Missing = 4
/* Lesson 06-3 */ /* File Name = les0603.sas 11/13/03 */ data gakusei; infile 'all03b.prn' firstobs=2; input sex $ height weight chest jitaku $ kodukai carrier $ tsuuwa; proc format; value clheight 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=10); run; proc tabulate data=gakusei; : 要約統計量の表の作成 class sex jitaku; : 特性変数であることの宣言 var kodukai; : 集計する変量名 tables kodukai*(n mean std),sex*jitaku; : 表示内容、分類変量名 run; : proc tabulate data=gakusei; : class height sex; : var weight; : tables weight*(n mean std),height*sex; : format height clheight.; : 連続変量をグループ化することの指定 run; :
SAS システム 2 14:05 Wednesday, November 12, 2003 ---------------------------------------------------------------------- | | SEX | | |---------------------------------------------------| | | F | M | | |-------------------------+-------------------------| | | JITAKU | JITAKU | | |-------------------------+-------------------------| | | G | J | G | J | |----------------+------------+------------+------------+------------| |KODUKAI|N | 23.00| 48.00| 59.00| 92.00| | |--------+------------+------------+------------+------------| | |MEAN | 92391.30| 36739.58| 88864.41| 26532.61| | |--------+------------+------------+------------+------------| | |STD | 64365.25| 34379.61| 54607.20| 36906.31| ---------------------------------------------------------------------- SAS システム 3 14:05 Wednesday, November 12, 2003 ---------------------------------------------------------------------- | | HEIGHT | | |---------------------------------------------------| | | -149 | 150-159 | 160-169 | | |------------+-------------------------+------------| | | SEX | SEX | SEX | | |------------+-------------------------+------------| | | F | F | M | F | |----------------+------------+------------+------------+------------| |WEIGHT |N | 4.00| 25.00| 1.00| 26.00| | |--------+------------+------------+------------+------------| | |MEAN | 42.00| 47.38| 61.00| 50.67| | |--------+------------+------------+------------+------------| | |STD | 2.94| 4.85| .| 3.33| ---------------------------------------------------------------------- (CONTINUED) SAS システム 4 14:05 Wednesday, November 12, 2003 ---------------------------------------------------------------------- | | HEIGHT | | |---------------------------------------------------| | | 160-169 | 170-179 | 180- | | |------------+-------------------------+------------| | | SEX | SEX | SEX | | |------------+-------------------------+------------| | | M | F | M | M | |----------------+------------+------------+------------+------------| |WEIGHT |N | 48.00| 0.00| 106.00| 18.00| | |--------+------------+------------+------------+------------| | |MEAN | 58.20| .| 62.88| 67.31| | |--------+------------+------------+------------+------------| | |STD | 7.24| .| 6.97| 8.35| ----------------------------------------------------------------------
data gakusei; infile 'all03b.prn' firstobs=2; input sex $ height weight chest jitaku $ kodukai carrier $ tsuuwa; : if carrier='J-PHONE' then carrier='Vodafone'; : 置き換え(再定義) : (以下略)
Cumulative Cumulative CARRIER Frequency Percent Frequency Percent ------------------------------------------------------ DDIp 2 4.0 2 4.0 DoCoMo 25 50.0 27 54.0 No 3 6.0 30 60.0 Vodafone 12 24.0 42 84.0 au 8 16.0 50 100.0 Frequency Missing = 215 TABLE OF SEX BY CARRIER SEX CARRIER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |No |Vodafone|au | Total ---------+--------+--------+--------+--------+--------+ F | 1 | 12 | 1 | 5 | 2 | 21 | 2.04 | 24.49 | 2.04 | 10.20 | 4.08 | 42.86 | 4.76 | 57.14 | 4.76 | 23.81 | 9.52 | | 50.00 | 48.00 | 33.33 | 45.45 | 25.00 | ---------+--------+--------+--------+--------+--------+ M | 1 | 13 | 2 | 6 | 6 | 28 | 2.04 | 26.53 | 4.08 | 12.24 | 12.24 | 57.14 | 3.57 | 46.43 | 7.14 | 21.43 | 21.43 | | 50.00 | 52.00 | 66.67 | 54.55 | 75.00 | ---------+--------+--------+--------+--------+--------+ Total 2 25 3 11 8 49 4.08 51.02 6.12 22.45 16.33 100.00 Frequency Missing = 216
data mon2003; infile 'd:\home\mon_all8d.csv' dlm=',' firstobs=2 truncover;
data mon2003; infile 'd:\home\mon_all8d.txt' dlm='09'x firstobs=2 truncover;