/* Lesson 10-1 */
/* File Name = les1001.sas 06/23/05 */
data gakusei;
infile 'all05a.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
21:12 Monday, June 20, 2005
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=SHINTYOU
Normal Probability Plot
172.5+ ++*++*
| *****+*+**+*
| **********+
| *********+
| +*******+
147.5+*++*+*++**
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 15
21:12 Monday, June 20, 2005
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=TAIJYUU
Normal Probability Plot
57.5+ ***+**+*+++*
| ***********+*
47.5+ **********++
| **+***+**++
37.5++*+++*+
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 22
21:12 Monday, June 20, 2005
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=KYOUI
Normal Probability Plot
92.5+ +++*++++
| **********+**+++*
82.5+ *****+***+*+++++
| +++*+*+**++++
72.5+++++*
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 29
21:12 Monday, June 20, 2005
-------------------------------- SEX=F ---------------------------------
Univariate Procedure
Variable=KODUKAI
Normal Probability Plot
325000+ *
|
| *
175000+ *** ++++
| *****+++++
| +**********
25000+* * *********************
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 36
21:12 Monday, June 20, 2005
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=SHINTYOU
Normal Probability Plot
187.5+ **
| *******+**+
| *********+
172.5+ ***********
| *********++
| ********++
157.5+**+
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 43
21:12 Monday, June 20, 2005
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=TAIJYUU
Normal Probability Plot
105+ *
| * *
| ** +++
75+ +*******+*+++
| ***************
| ****************+
45+**++*+++++
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 50
21:12 Monday, June 20, 2005
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=KYOUI
Normal Probability Plot
115+ * *
| ****++++++++
| ************+*
85+ *************++
| +*++***+++++
|++++
55+ *
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
SAS システム 57
21:12 Monday, June 20, 2005
-------------------------------- SEX=M ---------------------------------
Univariate Procedure
Variable=KODUKAI
Normal Probability Plot
325000+ *
|
| *
175000+ ***** ***+++
| ******+++++++
| ++******++
25000+** **************************
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
/* Lesson 10-2 */
/* File Name = les1002.sas 06/23/05 */
data gakusei;
infile 'all05a.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
21:12 Monday, June 20, 2005
TTEST PROCEDURE
Variable: SHINTYOU
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 105 159.07809524 5.48715249 0.53549125
M 207 172.05555556 5.45567804 0.37919584
Variances T DF Prob>|T|
---------------------------------------
Unequal -19.7780 208.0 0.0001
Equal -19.8154 310.0 0.0000
For H0: Variances are equal, F' = 1.01 DF = (104,206) Prob>F' = 0.9313
SAS システム 3
21:12 Monday, June 20, 2005
TTEST PROCEDURE
Variable: TAIJYUU
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 74 48.61081081 4.76435301 0.55384479
M 207 62.11497585 7.95609419 0.55298677
Variances T DF Prob>|T|
---------------------------------------
Unequal -17.2544 215.3 0.0001
Equal -13.7375 279.0 0.0000
For H0: Variances are equal, F' = 2.79 DF = (206,73) Prob>F' = 0.0000
SAS システム 4
21:12 Monday, June 20, 2005
TTEST PROCEDURE
Variable: KYOUI
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 39 83.10256410 4.03142179 0.64554413
M 65 88.52307692 8.55333943 1.06091119
Variances T DF Prob>|T|
---------------------------------------
Unequal -4.3648 97.6 0.0001
Equal -3.7126 102.0 0.0003
For H0: Variances are equal, F' = 4.50 DF = (64,38) Prob>F' = 0.0000
SAS システム 5
21:12 Monday, June 20, 2005
TTEST PROCEDURE
Variable: KODUKAI
SEX N Mean Std Dev Std Error
-----------------------------------------------------------------------
F 102 49044.11764706 46049.91388717 4559.62090897
M 198 48176.76767677 50521.18282832 3590.38412338
Variances T DF Prob>|T|
---------------------------------------
Unequal 0.1495 221.4 0.8813
Equal 0.1451 298.0 0.8847
For H0: Variances are equal, F' = 1.20 DF = (197,101) Prob>F' = 0.2987
/* Lesson 10-3 */
/* File Name = les1003.sas 06/23/05 */
data gakusei;
infile 'all05a.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
21:13 Monday, June 20, 2005
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 105 6514.0 16432.5000 752.445341 62.038095
M 207 42314.0 32395.5000 752.445341 204.415459
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 3
21:13 Monday, June 20, 2005
N P A R 1 W A Y P R O C E D U R E
S = 6514.00 Z = -13.1810 Prob > |Z| = 0.0001
T-Test Approx. Significance = 0.0001
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 173.76 DF = 1 Prob > CHISQ = 0.0001
SAS システム 4
21:13 Monday, June 20, 2005
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 74 3483.5000 10434.0 599.430726 47.074324
M 207 36137.5000 29187.0 599.430726 174.577295
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 5
21:13 Monday, June 20, 2005
N P A R 1 W A Y P R O C E D U R E
S = 3483.50 Z = -11.5943 Prob > |Z| = 0.0001
T-Test Approx. Significance = 0.0001
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 134.45 DF = 1 Prob > CHISQ = 0.0001
SAS システム 6
21:13 Monday, June 20, 2005
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 39 1377.0 2047.50000 148.164652 35.3076923
M 65 4083.0 3412.50000 148.164652 62.8153846
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 7
21:13 Monday, June 20, 2005
N P A R 1 W A Y P R O C E D U R E
S = 1377.00 Z = -4.52200 Prob > |Z| = 0.0001
T-Test Approx. Significance = 0.0001
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 20.479 DF = 1 Prob > CHISQ = 0.0001
SAS システム 8
21:13 Monday, June 20, 2005
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 102 16198.0 15351.0 708.064743 158.803922
M 198 28952.0 29799.0 708.064743 146.222222
Average Scores Were Used for Ties
Wilcoxon 2-Sample Test (Normal Approximation)
(with Continuity Correction of .5)
SAS システム 9
21:13 Monday, June 20, 2005
N P A R 1 W A Y P R O C E D U R E
S = 16198.0 Z = 1.19551 Prob > |Z| = 0.2319
T-Test Approx. Significance = 0.2328
Kruskal-Wallis Test (Chi-Square Approximation)
CHISQ = 1.4309 DF = 1 Prob > CHISQ = 0.2316
/* Lesson 10-4 */
/* File Name = les1004.sas 06/23/05 */
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
21:13 Monday, June 20, 2005
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
21:13 Monday, June 20, 2005
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
21:13 Monday, June 20, 2005
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
21:13 Monday, June 20, 2005
Univariate Procedure
Variable=DIF
Normal Probability Plot
0.25+ *++++*
| *++*+++
| *++++
-0.05+ *+++*++
| +++++
| ++++++
-0.35+ +++++ *
+----+----+----+----+----+----+----+----+----+----+
-2 -1 0 +1 +2
data seito05;
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;
...
[比較演算子]
[論理演算子]