/* Lesson 22-1 */
/* File Name = les2201.sas 11/21/02 */
/* */
/* Original File Name = les1001.sas 06/20/02 */
/* Original File Name = les1002.sas 06/20/02 */
data gakusei;
infile 'all02.prn' firstobs=2;
input sex $ height weight chest
jitaku $ kodukai carrier $ tsuuwa;
proc print data=gakusei(obs=10);
run;
proc freq data=gakusei;
tables sex*jitaku/chisq;
tables sex*jitaku/chisq norow nocol nopercent;
run;
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 freq data=gakusei;
tables height*sex/chisq norow nocol nopercent;
format height clheight.;
run;
SAS システム 2
20:48 Wednesday, November 20, 2002
TABLE OF SEX BY JITAKU
SEX JITAKU
Frequency|
Percent |
Row Pct |
Col Pct |G |J | Total
---------+--------+--------+
F | 20 | 48 | 68
| 9.43 | 22.64 | 32.08
| 29.41 | 70.59 |
| 26.67 | 35.04 |
---------+--------+--------+
M | 55 | 89 | 144
| 25.94 | 41.98 | 67.92
| 38.19 | 61.81 |
| 73.33 | 64.96 |
---------+--------+--------+
Total 75 137 212
35.38 64.62 100.00
Frequency Missing = 31
SAS システム 5
20:48 Wednesday, November 20, 2002
STATISTICS FOR TABLE OF SEX BY JITAKU
Statistic DF Value Prob
------------------------------------------------------
Chi-Square 1 1.558 0.212
Likelihood Ratio Chi-Square 1 1.584 0.208
Continuity Adj. Chi-Square 1 1.198 0.274
Mantel-Haenszel Chi-Square 1 1.551 0.213
Fisher's Exact Test (Left) 0.137
(Right) 0.921
(2-Tail) 0.223
Phi Coefficient -0.086
Contingency Coefficient 0.085
Cramer's V -0.086
Effective Sample Size = 212
Frequency Missing = 31
WARNING: 13% のデータが欠損です.
SAS システム 7
20:48 Wednesday, November 20, 2002
TABLE OF SEX BY JITAKU
SEX JITAKU
Frequency|G |J | Total
---------+--------+--------+
F | 20 | 48 | 68
---------+--------+--------+
M | 55 | 89 | 144
---------+--------+--------+
Total 75 137 212
Frequency Missing = 31
SAS システム 10
20:48 Wednesday, November 20, 2002
TABLE OF HEIGHT BY SEX
HEIGHT SEX
Frequency|F |M | Total
---------+--------+--------+
-149 | 5 | 0 | 5
---------+--------+--------+
150-159 | 29 | 1 | 30
---------+--------+--------+
160-169 | 36 | 45 | 81
---------+--------+--------+
170-179 | 2 | 98 | 100
---------+--------+--------+
180- | 0 | 17 | 17
---------+--------+--------+
Total 72 161 233
Frequency Missing = 10
SAS システム 12
20:48 Wednesday, November 20, 2002
STATISTICS FOR TABLE OF HEIGHT BY SEX
Statistic DF Value Prob
------------------------------------------------------
Chi-Square 4 125.627 0.001
Likelihood Ratio Chi-Square 4 148.468 0.001
Mantel-Haenszel Chi-Square 1 113.962 0.001
Phi Coefficient 0.734
Contingency Coefficient 0.592
Cramer's V 0.734
Effective Sample Size = 233
Frequency Missing = 10
data rei01; do i=1 to 200; x=rannor(12345); output; end; run;
/* Lesson 22-2 */ /* File Name = les2202.sas 11/21/02 */ options linesize=72; /* pagesize=20; */ : 出力サイズの指定 data rei01; : データセット名を rei01 とする do i=1 to 200; : 200回の繰り返し x=rannor(12345); : 正規乱数を発生させる output; : データセットに追加する end; : 繰り返しの終端 run; : proc print data=rei01(obs=10); : 先頭 10ケースの表示 run; : proc means data=rei01; : 全データに対する平均の計算 run; : proc print data=rei01(firstobs=91 obs=110); : 91番から 110番のデータの表示 run; : proc means data=rei01(firstobs=91 obs=110); : 91番から 110番のデータについての平均 run; : data _null_; : データセット名は付けない set rei01; : 元となるデータセット名 file "unsorted.dat"; : 出力ファイル名 put i 5. x 15.8; : 変量 i は小数点以上 5桁で run; : 変量 x は小数点以上 15桁、以下 8桁で proc sort data=rei01; : 並べ替え by x; : 変量 x について run; : proc print data=rei01(obs=10); run; proc print data=rei01(firstobs=91 obs=110); run; proc means data=rei01(firstobs=91 obs=110); run; data _null_; set rei01; file "sorted.dat"; put i 5. x 15.8; run;
/* Lesson 22-3 */
/* File Name = les2203.sas 11/21/02 */
options linesize=72; /* pagesize=20; */
data rei02; : データセット名を rei02 とする
do i=1 to 100; :
x=rannor(23456); : 上記とは別の種で乱数を発生させる
x10=int(x*10); : 10倍して正数部分だけ利用
output; :
end; :
run; :
title "Default"; : 見出し(タイトル)を付ける : 「無指定」
proc chart data=rei02; : オプションを指定しない場合のヒストグラム
hbar x; : 変量 x について
run; :
title "Ascending order"; : 「昇順」
proc chart data=rei02; :
hbar x / midpoints=-3 to 3 by .5; : 変量 x について昇順で。0.5 刻み。
run; :
title "Descending order"; : 「降順」
proc chart data=rei02; :
hbar x / midpoints=3 to -3 by -.5; : 変量 x について降順で。-0.5 刻み。
run; :
title "Default"; : 「無指定」: x10 を昇順に表示
proc freq data=rei02; : オプションを指定しない場合の度数分布表
tables x10; : 変量 x10 について
run; :
title "Freqency order"; : 「頻度降順」: 頻度の大きいものから
proc freq data=rei02 order=freq; :
tables x10; : 変量 x10 についての頻度順に表示
run; :
proc sort data=rei02; : 並べ替え
by decending x10; : x10 について降順に並べる
run; :
title "Descending order"; : 「数値降順」: x10 を降順に表示
proc freq data=rei02 order=data; : データの出現順で表示させるというオプション
tables x10; :
run; :