/* Lesson 9-1 */ /* File Name = les0901.sas 06/13/02 */ /* modified from les0702.sas */ data gakusei; infile 'waseda02.prn'; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carrier $ tsuuwa; title "*** Whole data ***"; : 各頁にタイトルを表示させる proc print data=gakusei(obs=5); run; proc means data=gakusei; var shintyou kodukai; : 変量を指定 run; proc chart data=gakusei; hbar shintyou kodukai; : 変量を指定 run; proc univariate data=gakusei plot; var shintyou kodukai; : 変量を指定 run; proc sort data=gakusei; by sex; run; proc means data=gakusei; var shintyou kodukai; : 変量を指定 by sex; run; proc chart data=gakusei; hbar shintyou kodukai/group=sex; : 変量を指定 run; proc chart data=gakusei; : hbar shintyou kodukai/group=jitaku; : 自宅生/下宿生での比較 run; : title "*** Truncated data ***"; : 各頁にタイトルを表示させる data truncate; : 新しいデータに名前を付ける set gakusei; : 元データを持ってくる if kodukai > 200000 then delete; : 外れ値を含むサンプルを削除する proc print data=truncate(obs=5); : 対象データ名を変更 run; proc means data=truncate; : 対象データ名を変更 var shintyou kodukai; run; proc chart data=truncate; : 対象データ名を変更 hbar shintyou kodukai; run; proc univariate data=truncate plot; : 対象データ名を変更 var shintyou kodukai; run; proc sort data=truncate; : 対象データ名を変更 by sex; run; proc means data=truncate; : 対象データ名を変更 var shintyou kodukai; by sex; run; proc chart data=truncate; : 対象データ名を変更 hbar shintyou kodukai/group=sex; run; proc chart data=truncate; : 対象データ名を変更 hbar shintyou kodukai/group=jitaku; run;
*** Whole data *** 2 10:46 Wednesday, June 12, 2002 Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- SHINTYOU 38 165.8921053 8.6980390 148.0000000 181.5000000 KODUKAI 36 44888.89 57705.05 0 300000.00 -------------------------------------------------------------------- *** Whole data *** 4 10:46 Wednesday, June 12, 2002 KODUKAI Cum. Cum. Midpoint Freq Freq Percent Percent | 0 |***************** 17 17 47.22 47.22 60000 |************* 13 30 36.11 83.33 120000 |***** 5 35 13.89 97.22 180000 | 0 35 0.00 97.22 240000 | 0 35 0.00 97.22 300000 |* 1 36 2.78 100.00 | -----+----+----+-- 5 10 15 Frequency *** Whole data *** 11 10:46 Wednesday, June 12, 2002 Univariate Procedure Variable=KODUKAI Quantiles(Def=5) 100% Max 300000 99% 300000 75% Q3 60000 95% 125000 50% Med 30000 90% 120000 25% Q1 4000 10% 0 0% Min 0 5% 0 1% 0 Range 300000 Q3-Q1 56000 Mode 0 *** Whole data *** 14 10:46 Wednesday, June 12, 2002 Univariate Procedure Variable=KODUKAI Stem Leaf # Boxplot 3 0 1 * 2 2 1 1 00222 5 | 0 5566677 7 +-----+ 0 00000000000122222333444 23 *--+--* ----+----+----+----+--- Multiply Stem.Leaf by 10**+5 *** Whole data *** 21 10:46 Wednesday, June 12, 2002 SEX KODUKAI Cum. Cum. Midpoint Freq Freq Percent Percent | F 0 |*** 3 4 8.33 11.11 60000 |********** 10 14 27.78 38.89 120000 |*** 3 17 8.33 47.22 180000 | 0 17 0.00 47.22 240000 | 0 17 0.00 47.22 300000 | 0 17 0.00 47.22 | M 0 |************* 13 30 36.11 83.33 60000 |*** 3 33 8.33 91.67 120000 |** 2 35 5.56 97.22 180000 | 0 35 0.00 97.22 240000 | 0 35 0.00 97.22 300000 |* 1 36 2.78 100.00 | -----+----+--- 5 10 Frequency *** Whole data *** 25 10:46 Wednesday, June 12, 2002 JITAKU KODUKAI Cum. Cum. Midpoint Freq Freq Percent Percent | G 0 |********** 5 7 13.89 19.44 60000 |********** 5 12 13.89 33.33 120000 |****** 3 15 8.33 41.67 180000 | 0 15 0.00 41.67 240000 | 0 15 0.00 41.67 300000 | 0 15 0.00 41.67 | J 0 |******************** 10 25 27.78 69.44 60000 |**************** 8 33 22.22 91.67 120000 |**** 2 35 5.56 97.22 180000 | 0 35 0.00 97.22 240000 | 0 35 0.00 97.22 300000 |** 1 36 2.78 100.00 | ----+---+---+---+---+ 2 4 6 8 10 Frequency *** Truncated data *** 28 10:46 Wednesday, June 12, 2002 Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- SHINTYOU 37 165.5378378 8.5355580 148.0000000 181.5000000 KODUKAI 35 37600.00 38196.24 0 125000.00 -------------------------------------------------------------------- *** Truncated data *** 30 10:46 Wednesday, June 12, 2002 KODUKAI Cum. Cum. Midpoint Freq Freq Percent Percent | 0 |************************ 12 12 34.29 34.29 25000 |****************** 9 21 25.71 60.00 50000 |************** 7 28 20.00 80.00 75000 |**** 2 30 5.71 85.71 100000 |**** 2 32 5.71 91.43 125000 |****** 3 35 8.57 100.00 | ----+---+---+---+---+---+ 2 4 6 8 10 12 Frequency *** Truncated data *** 37 10:46 Wednesday, June 12, 2002 Univariate Procedure Variable=KODUKAI Quantiles(Def=5) 100% Max 125000 99% 125000 75% Q3 60000 95% 120000 50% Med 30000 90% 100000 25% Q1 4000 10% 0 0% Min 0 5% 0 1% 0 Range 125000 Q3-Q1 56000 Mode 0 *** Truncated data *** 40 10:46 Wednesday, June 12, 2002 Univariate Procedure Variable=KODUKAI Stem Leaf # Boxplot 12 005 3 | 10 00 2 | 8 | 6 0000 4 +-----+ 4 00005 5 | | 2 000350005 9 *--+--* 0 000000004450 12 +-----+ ----+----+----+----+ Multiply Stem.Leaf by 10**+4 *** Truncated data *** 43 10:46 Wednesday, June 12, 2002 --------------------------------- SEX=F -------------------------------- Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- SHINTYOU 17 158.7941176 6.3222297 148.0000000 171.0000000 KODUKAI 16 52187.50 36604.59 0 125000.00 -------------------------------------------------------------------- *** Truncated data *** 44 10:46 Wednesday, June 12, 2002 --------------------------------- SEX=M -------------------------------- Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- SHINTYOU 19 171.4421053 5.4860749 160.0000000 181.5000000 KODUKAI 18 25444.44 36964.57 0 120000.00 -------------------------------------------------------------------- *** Truncated data *** 47 10:46 Wednesday, June 12, 2002 SEX KODUKAI Cum. Cum. Midpoint Freq Freq Percent Percent | F 0 |****** 3 4 8.57 11.43 25000 |****** 3 7 8.57 20.00 50000 |********** 5 12 14.29 34.29 75000 |**** 2 14 5.71 40.00 100000 |**** 2 16 5.71 45.71 125000 |** 1 17 2.86 48.57 | M 0 |****************** 9 26 25.71 74.29 25000 |********** 5 31 14.29 88.57 50000 |**** 2 33 5.71 94.29 75000 | 0 33 0.00 94.29 100000 | 0 33 0.00 94.29 125000 |**** 2 35 5.71 100.00 | ----+---+---+---+-- 2 4 6 8 Frequency *** Truncated data *** 51 10:46 Wednesday, June 12, 2002 JITAKU KODUKAI Cum. Cum. Midpoint Freq Freq Percent Percent | G 0 |****** 3 5 8.57 14.29 25000 |**** 2 7 5.71 20.00 50000 |****** 3 10 8.57 28.57 75000 |**** 2 12 5.71 34.29 100000 |** 1 13 2.86 37.14 125000 |**** 2 15 5.71 42.86 | J 0 |**************** 8 23 22.86 65.71 25000 |************ 6 29 17.14 82.86 50000 |******** 4 33 11.43 94.29 75000 | 0 33 0.00 94.29 100000 |** 1 34 2.86 97.14 125000 |** 1 35 2.86 100.00 | ----+---+---+---+ 2 4 6 8 Frequency
data seito02; infile 'seito.prn'; input id $ sex $ kesseki $ koku $ suu1 $ suu2 $ tireki $ koumin $ rika $; if sex^='M' then delete; /* male only */ if kesseki^='0' then delete; /* syusseki-sya only */ if tireki="世界史-0" then tireki="世界史"; if tireki="世界史-2" then tireki="世界史"; if tireki="日本史-2" then tireki="日本史"; if tireki="日本史-3" then tireki="日本史"; ...
[例3] 複数の処理をさせたい場合 : do 〜 end で囲む
if tireki="世界史-0" then do; tireki="世界史"; koumin=.; end; ...
[比較演算子]
[論理演算子]
data math; infile 'foomath.dat' lrecl=230;
data math; infile 'foomath.dat' lrecl=230 truncover;
input kamoku $ 2 kesseki $ 3 k_code $ 10-11 t_score 12-14 s_scor01 103-104 s_scor02 105-106 s_scor03 107-108 s_scor04 109-110 ;
data math; infile 'foo.dat' firstobs=4;