/* Lesson 09-1 */
/* File Name = les0901.sas 06/22/06 */
data gakusei;
infile 'all06ae.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
if sex^='M' & sex^='F' then delete; : 性別不明は除外する
proc print data=gakusei(obs=5);
run;
proc sort data=gakusei;
by sex;
run;
proc univariate data=gakusei plot;
var shintyou taijyuu kyoui kodukai;
by sex;
run;
SAS システム 8
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=SHINTYOU
Normal Probability Plot
172.5+ +*++*
| ********+*+*
| **********+
| **********+
| ********+
147.5+*++*+*++**
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 15
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=TAIJYUU
Normal Probability Plot
57.5+ *****+*+++*
| **********+*+
47.5+ **********++
| ****+**+*++
37.5++*+++*+
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 22
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=KYOUI
Normal Probability Plot
92.5+ ++++*+++
| **********+*+*+++*
82.5+ *******+*+**+++++
| ++*++**+*++++
72.5++++*+
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 29
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=KODUKAI
Normal Probability Plot
325000+ *
|
| *
175000+ ** * +++
| *****++++++
| +**********
25000+* * * ********************
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 36
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=SHINTYOU
Normal Probability Plot
187.5+ +*
| ******+**++
| *********++
172.5+ ***********+
| *********+
| *+*******+
157.5+*++
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 43
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=TAIJYUU
Normal Probability Plot
105+ *
| * *
| ** +++
75+ *********+*++
| ***************
| *****************+
45+*+++*+++++
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 50
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=KYOUI
Normal Probability Plot
115+ * *
| ***+*+++++++
| ***********+*+
85+ *************++
| ++*+*+**++++
|+++
55+ *
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 57
23:23 Tuesday, June 13, 2006
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=KODUKAI
Normal Probability Plot
325000+ *
|
| *
175000+ ****** *+*++
| ******++++++
| ++*******+
25000+*** *************************
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
/* Lesson 09-2 */
/* File Name = les0902.sas 06/22/06 */
data gakusei;
infile 'all06ae.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
if sex^='M' & sex^='F' then delete;
proc print data=gakusei(obs=10);
run;
proc ttest data=gakusei; : t検定
class sex; : 分類したい特性変数の指定
var shintyou taijyuu kyoui kodukai; : 比較したい変量名
run; :
SAS システム 2
23:23 Tuesday, June 13, 2006
TTEST PROCEDURE
Variable: SHINTYOU
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 110 159.12909091 5.39463453 0.51435822
M 228 172.20350877 5.41497239 0.35861531
Variances T DF Prob>|T|
---------------------------------------
Unequal -20.8513 216.2 0.0001
Equal -20.8238 336.0 0.0000
For H0: Variances are equal, F' = 1.01 DF = (227,109) Prob>F' = 0.9790
SAS システム 3
23:23 Tuesday, June 13, 2006
TTEST PROCEDURE
Variable: TAIJYUU
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 78 48.62820513 4.67640936 0.52949909
M 228 62.16140351 7.89955677 0.52316093
Variances T DF Prob>|T|
---------------------------------------
Unequal -18.1811 227.3 0.0001
Equal -14.2885 304.0 0.0000
For H0: Variances are equal, F' = 2.85 DF = (227,77) Prob>F' = 0.0000
SAS システム 4
23:23 Tuesday, June 13, 2006
TTEST PROCEDURE
Variable: KYOUI
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 42 82.95238095 3.93825751 0.60768633
M 69 88.60869565 8.33881320 1.00387514
Variances T DF Prob>|T|
---------------------------------------
Unequal -4.8201 103.8 0.0001
Equal -4.1198 109.0 0.0001
For H0: Variances are equal, F' = 4.48 DF = (68,41) Prob>F' = 0.0000
SAS システム 5
23:23 Tuesday, June 13, 2006
TTEST PROCEDURE
Variable: KODUKAI
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 107 48579.43925234 45373.45815940 4386.41776369
M 218 47220.18348624 49351.52901010 3342.50731003
Variances T DF Prob>|T|
---------------------------------------
Unequal 0.2465 227.4 0.8055
Equal 0.2395 323.0 0.8109
For H0: Variances are equal, F' = 1.18 DF = (217,106) Prob>F' = 0.3310
/* Lesson 09-3 */
/* File Name = les0903.sas 06/22/06 */
data gakusei;
infile 'all06ae.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
if sex^='M' & sex^='F' then delete;
proc print data=gakusei(obs=10);
run;
proc npar1way data=gakusei wilcoxon; : wilcoxon 検定
class sex; : 分類したい特性変数の指定
var shintyou taijyuu kyoui kodukai; : 比較したい変量名
run; :
SAS システム 2
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
Wilcoxon Scores (Rank Sums) for Variable SHINTYOU
Classified by Variable SEX
Sum of Expected Std Dev Mean
SEX N Scores Under H0 Under H0 Score
F 110 7137.0 18645.0 841.174446 64.881818
M 228 50154.0 38646.0 841.174446 219.973684
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 3
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
S = 7137.00 Z = -13.6803 Prob > |Z| = 0.0001
T-Test Approx. Significance = 0.0001
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 187.17 DF = 1 Prob > CHISQ = 0.0001
SAS システム 4
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
Wilcoxon Scores (Rank Sums) for Variable TAIJYUU
Classified by Variable SEX
Sum of Expected Std Dev Mean
SEX N Scores Under H0 Under H0 Score
F 78 3880.5000 11973.0 673.901338 49.750000
M 228 43090.5000 34998.0 673.901338 188.993421
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 5
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
S = 3880.50 Z = -12.0077 Prob > |Z| = 0.0001
T-Test Approx. Significance = 0.0001
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 144.20 DF = 1 Prob > CHISQ = 0.0001
SAS システム 6
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
Wilcoxon Scores (Rank Sums) for Variable KYOUI
Classified by Variable SEX
Sum of Expected Std Dev Mean
SEX N Scores Under H0 Under H0 Score
F 42 1544.0 2352.0 163.610894 36.7619048
M 69 4672.0 3864.0 163.610894 67.7101449
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 7
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
S = 1544.00 Z = -4.93549 Prob > |Z| = 0.0001
T-Test Approx. Significance = 0.0001
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 24.389 DF = 1 Prob > CHISQ = 0.0001
SAS システム 8
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
Wilcoxon Scores (Rank Sums) for Variable KODUKAI
Classified by Variable SEX
Sum of Expected Std Dev Mean
SEX N Scores Under H0 Under H0 Score
F 107 18462.5000 17441.0 792.073100 172.546729
M 218 34512.5000 35534.0 792.073100 158.314220
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 9
23:23 Tuesday, June 13, 2006
N P A R 1 W A Y P R O C E D U R E
S = 18462.5 Z = 1.28902 Prob > |Z| = 0.1974
T-Test Approx. Significance = 0.1983
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 1.6632 DF = 1 Prob > CHISQ = 0.1972
/* Lesson 09-4 */
/* File Name = les0904.sas 06/22/06 */
data pair; :
input x y @@; : @@ は 1行に複数のデータがあることを示す
dif=x-y; : 差(difference)を計算する
cards; : データをプログラム内に記述する
3.51 3.39 3.07 3.39 3.29 3.20 3.03 3.11 : x1,y1, x2,y2, x3,y3, x4,y4,
3.38 3.17 3.30 3.09 3.15 3.17 3.25 3.09 : x5,y5, x6,y6, x7,y7, x8,y8
; :
:
proc print data=pair; :
run; :
proc univariate data=pair plot; :
var dif; : 差について
run; :
SAS システム 1
23:23 Tuesday, June 13, 2006
OBS X Y DIF
1 3.51 3.39 0.12
2 3.07 3.39 -0.32
3 3.29 3.20 0.09
4 3.03 3.11 -0.08
5 3.38 3.17 0.21
6 3.30 3.09 0.21
7 3.15 3.17 -0.02
8 3.25 3.09 0.16
SAS システム 2
23:23 Tuesday, June 13, 2006
Univariate Procedure
Variable=DIF
Moments
N 8 Sum Wgts 8
Mean 0.04625 Sum 0.37
Std Dev 0.180629 Variance 0.032627
Skewness -1.31523 Kurtosis 1.511099
USS 0.2455 CSS 0.228388
CV 390.5489 Std Mean 0.063862
T:Mean=0 0.724218 Pr>|T| 0.4924
Num ^= 0 8 Num > 0 5
M(Sign) 1 Pr>=|M| 0.7266
Sgn Rank 7 Pr>=|S| 0.3594
SAS システム 5
23:23 Tuesday, June 13, 2006
Univariate Procedure
Variable=DIF
Stem Leaf # Boxplot
2 11 2 |
1 26 2 +-----+
0 9 1 | + |
-0 82 2 +-----+
-1 |
-2 |
-3 2 1 |
----+----+----+----+
Multiply Stem.Leaf by 10**-1
SAS システム 6
23:23 Tuesday, June 13, 2006
Univariate Procedure
Variable=DIF
Normal Probability Plot
0.25+ *++++*
| *++*+++
| *++++
-0.05+ *+++*++
| +++++
| ++++++
-0.35+ +++++ *
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
data seito06;
infile 'seito.prn';
input id $ sex $ kesseki $ univ $
koku $ suu1 $ suu2 $ tireki $ koumin $ rika $;
if sex^='M' then delete; /* male only */
if kesseki^='0' then delete; /* syusseki-sya only */
area="不明";
if univ="早稲田大学" then area="東日本";
if univ="慶応大学" then area="東日本";
if univ="関西大学" then area="西日本";
if univ="同志社大学" then area="西日本";
if tireki="世界史-0" then tireki="世界史";
if tireki="世界史-2" then tireki="世界史";
if tireki="日本史-2" then tireki="日本史";
if tireki="日本史-3" then tireki="日本史";
...
[例4] 複数の処理をさせたい場合 : do 〜 end で囲む
if tireki="世界史-0" then do;
tireki="世界史";
koumin=.;
end;
...
[比較演算子]
[論理演算子]
data gakusei; infile 'all06ae.prn' firstobs=2; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carryer $ tsuuwa; dekasa=shintyou+taijyuu+kyoui; : 変量間の加減乗除 kyo_2=kyoui**2; : 二乗 kyo_sr=sqrt(kyoui); : ルート
[算術演算子]
[数値関数]
data randnum; do i=1 to 200; x=rannor(12345); output; end; run;プログラム例 : les0905.sas、 出力結果 : les0905.lst
[乱数関数] : 乱数を生成する関数