/* Lesson 10-1 */ /* File Name = les0701.sas 05/29/03 */ data gakusei; : infile 'all03a.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 14:07 Monday, May 26, 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.7 41.5 80 J 35000 . 8 F 152.0 35.0 77 J 60000 DoCoMo 2000 9 F 153.0 41.0 . J 125000 No . 10 F 153.0 46.5 87 G 10000 . SAS システム 2 14:07 Monday, May 26, 2003 Cumulative Cumulative SEX Frequency Percent Frequency Percent ------------------------------------------------- F 78 31.3 78 31.3 M 171 68.7 249 100.0 Frequency Missing = 3 Cumulative Cumulative JITAKU Frequency Percent Frequency Percent ---------------------------------------------------- G 80 36.0 80 36.0 J 142 64.0 222 100.0 Frequency Missing = 30 Cumulative Cumulative CARRIER Frequency Percent Frequency Percent ----------------------------------------------------- DDIp 1 2.6 1 2.6 DoCoMo 19 50.0 20 52.6 J-PHONE 8 21.1 28 73.7 No 3 7.9 31 81.6 au 7 18.4 38 100.0 Frequency Missing = 214 SAS システム 4 14:07 Monday, May 26, 2003 TABLE OF SEX BY JITAKU SEX JITAKU Frequency| Percent | Row Pct | Col Pct |G |J | Total ---------+--------+--------+ F | 21 | 49 | 70 | 9.55 | 22.27 | 31.82 | 30.00 | 70.00 | | 26.58 | 34.75 | ---------+--------+--------+ M | 58 | 92 | 150 | 26.36 | 41.82 | 68.18 | 38.67 | 61.33 | | 73.42 | 65.25 | ---------+--------+--------+ Total 79 141 220 35.91 64.09 100.00 Frequency Missing = 32 SAS システム 7 14:07 Monday, May 26, 2003 TABLE OF SEX BY CARRIER SEX CARRIER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |J-PHONE |No |au | Total ---------+--------+--------+--------+--------+--------+ F | 0 | 9 | 3 | 1 | 2 | 15 | 0.00 | 24.32 | 8.11 | 2.70 | 5.41 | 40.54 | 0.00 | 60.00 | 20.00 | 6.67 | 13.33 | | 0.00 | 47.37 | 42.86 | 33.33 | 28.57 | ---------+--------+--------+--------+--------+--------+ M | 1 | 10 | 4 | 2 | 5 | 22 | 2.70 | 27.03 | 10.81 | 5.41 | 13.51 | 59.46 | 4.55 | 45.45 | 18.18 | 9.09 | 22.73 | | 100.00 | 52.63 | 57.14 | 66.67 | 71.43 | ---------+--------+--------+--------+--------+--------+ Total 1 19 7 3 7 37 2.70 51.35 18.92 8.11 18.92 100.00 Frequency Missing = 215 SAS システム 10 14:07 Monday, May 26, 2003 TABLE OF JITAKU BY CARRIER JITAKU CARRIER Frequency| Percent | Row Pct | Col Pct |DDIp |DoCoMo |J-PHONE |No |au | Total ---------+--------+--------+--------+--------+--------+ G | 1 | 6 | 2 | 0 | 4 | 13 | 2.86 | 17.14 | 5.71 | 0.00 | 11.43 | 37.14 | 7.69 | 46.15 | 15.38 | 0.00 | 30.77 | | 100.00 | 35.29 | 28.57 | 0.00 | 57.14 | ---------+--------+--------+--------+--------+--------+ J | 0 | 11 | 5 | 3 | 3 | 22 | 0.00 | 31.43 | 14.29 | 8.57 | 8.57 | 62.86 | 0.00 | 50.00 | 22.73 | 13.64 | 13.64 | | 0.00 | 64.71 | 71.43 | 100.00 | 42.86 | ---------+--------+--------+--------+--------+--------+ Total 1 17 7 3 7 35 2.86 48.57 20.00 8.57 20.00 100.00 Frequency Missing = 217
/* Lesson 10-2 */ /* File Name = les0702.sas 05/29/03 */ data gakusei; infile 'all03a.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 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 14:07 Monday, May 26, 2003 Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- -149 5 2.1 5 2.1 150-159 30 12.3 35 14.4 160-169 86 35.4 121 49.8 170-179 104 42.8 225 92.6 180- 18 7.4 243 100.0 Frequency Missing = 9 SAS システム 3 14:07 Monday, May 26, 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 | 29 | 38 | 2 | 0 | 74 | 2.07 | 11.98 | 15.70 | 0.83 | 0.00 | 30.58 | 6.76 | 39.19 | 51.35 | 2.70 | 0.00 | | 100.00 | 96.67 | 44.71 | 1.92 | 0.00 | ---------+--------+--------+--------+--------+--------+ M | 0 | 1 | 47 | 102 | 18 | 168 | 0.00 | 0.41 | 19.42 | 42.15 | 7.44 | 69.42 | 0.00 | 0.60 | 27.98 | 60.71 | 10.71 | | 0.00 | 3.33 | 55.29 | 98.08 | 100.00 | ---------+--------+--------+--------+--------+--------+ Total 5 30 85 104 18 242 2.07 12.40 35.12 42.98 7.44 100.00 Frequency Missing = 10 SAS システム 6 14:07 Monday, May 26, 2003 ------------------------------- SEX=' ' -------------------------------- Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- 160-169 1 100.0 1 100.0 Frequency Missing = 2 SAS システム 7 14:07 Monday, May 26, 2003 -------------------------------- SEX=F --------------------------------- Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- -149 5 6.8 5 6.8 150-159 29 39.2 34 45.9 160-169 38 51.4 72 97.3 170-179 2 2.7 74 100.0 Frequency Missing = 4 SAS システム 8 14:07 Monday, May 26, 2003 -------------------------------- SEX=M --------------------------------- Cumulative Cumulative HEIGHT Frequency Percent Frequency Percent ----------------------------------------------------- 150-159 1 0.6 1 0.6 160-169 47 28.0 48 28.6 170-179 102 60.7 150 89.3 180- 18 10.7 168 100.0 Frequency Missing = 3
/* Lesson 10-3 */ /* File Name = les0703.sas 05/29/03 */ data gakusei; infile 'all03a.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 height; : 集計する変量名 tables height*(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:07 Monday, May 26, 2003 ---------------------------------------------------------------------- | | SEX | | |---------------------------------------------------| | | F | M | | |-------------------------+-------------------------| | | JITAKU | JITAKU | | |-------------------------+-------------------------| | | G | J | G | J | |----------------+------------+------------+------------+------------| |HEIGHT |N | 20.00| 47.00| 58.00| 89.00| | |--------+------------+------------+------------+------------| | |MEAN | 160.52| 158.66| 172.55| 171.80| | |--------+------------+------------+------------+------------| | |STD | 5.66| 5.55| 4.80| 5.66| ---------------------------------------------------------------------- SAS システム 3 14:07 Monday, May 26, 2003 ---------------------------------------------------------------------- | | HEIGHT | | |---------------------------------------------------| | | -149 | 150-159 | 160-169 | | |------------+-------------------------+------------| | | SEX | SEX | SEX | | |------------+-------------------------+------------| | | F | F | M | F | |----------------+------------+------------+------------+------------| |WEIGHT |N | 4.00| 22.00| 1.00| 24.00| | |--------+------------+------------+------------+------------| | |MEAN | 42.00| 47.07| 61.00| 50.69| | |--------+------------+------------+------------+------------| | |STD | 2.94| 5.10| .| 3.46| ---------------------------------------------------------------------- (CONTINUED) SAS システム 4 14:07 Monday, May 26, 2003 ---------------------------------------------------------------------- | | HEIGHT | | |---------------------------------------------------| | | 160-169 | 170-179 | 180- | | |------------+-------------------------+------------| | | SEX | SEX | SEX | | |------------+-------------------------+------------| | | M | F | M | M | |----------------+------------+------------+------------+------------| |WEIGHT |N | 47.00| 0.00| 102.00| 18.00| | |--------+------------+------------+------------+------------| | |MEAN | 58.22| .| 62.91| 67.31| | |--------+------------+------------+------------+------------| | |STD | 7.31| .| 7.00| 8.35| ----------------------------------------------------------------------
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;
options linesize=72 pagesize=20;
sas les9999.sas