/* Lesson 11-1 */ /* File Name = les1101.sas 12/22/05 */ data gakusei; infile 'all05be.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:26 Wednesday, December 21, 2005 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=SHINTYOU Normal Probability Plot 172.5+ ++*++* | *****+*+**+* | *********++ | *********+ | +*******+ 147.5+*++*+*++** +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 15 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=TAIJYUU Normal Probability Plot 57.5+ *****+*+++* | **********+*+ 47.5+ ***********++ | ****+**+*++ 37.5++*+++*+ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 22 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=KYOUI Normal Probability Plot 92.5+ ++++*+++ | **********+*+*+++* 82.5+ *****+**+**+*+++ | ++*++**+*++++ 72.5++++*+ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 29 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=KODUKAI Normal Probability Plot 325000+ * | | * 175000+ ** * +++ | *****++++++ | +********** 25000+* * * ******************** +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 36 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=SHINTYOU Normal Probability Plot 187.5+ ** | *********++ | **********+ 172.5+ ***********+ | *********++ | *+*******+ 157.5+**+ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 43 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=TAIJYUU Normal Probability Plot 105+ * | ** | ** +++ 75+ *********+++ | **************** | ****************+ 45+**++*+++++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 50 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=KYOUI Normal Probability Plot 115+ * * | ***+*+++++++ | **********+*+* 85+ *************++ | +*+*+**++++ |++++ 55+ * +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 57 21:26 Wednesday, December 21, 2005 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=KODUKAI Normal Probability Plot 325000+ * | | * 175000+ ****** **+++ | *******++++++ | ++******++ 25000+** ************************** +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2
/* Lesson 11-2 */ /* File Name = les1102.sas 12/22/05 */ data gakusei; infile 'all05be.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:26 Wednesday, December 21, 2005 TTEST PROCEDURE Variable: SHINTYOU SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 108 159.12222222 5.44071417 0.52353297 M 219 172.12557078 5.45652408 0.36871773 Variances T DF Prob>|T| --------------------------------------- Unequal -20.3068 213.7 0.0001 Equal -20.2868 325.0 0.0000 For H0: Variances are equal, F' = 1.01 DF = (218,107) Prob>F' = 0.9875 SAS システム 3 21:26 Wednesday, December 21, 2005 TTEST PROCEDURE Variable: TAIJYUU SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 77 48.57142857 4.67993638 0.53332825 M 219 62.01735160 7.93620032 0.53627872 Variances T DF Prob>|T| --------------------------------------- Unequal -17.7779 226.6 0.0001 Equal -14.0248 294.0 0.0000 For H0: Variances are equal, F' = 2.88 DF = (218,76) Prob>F' = 0.0000 SAS システム 4 21:26 Wednesday, December 21, 2005 TTEST PROCEDURE Variable: KYOUI SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 41 83.02439024 3.95908957 0.61830591 M 67 88.49253731 8.43580596 1.03059773 Variances T DF Prob>|T| --------------------------------------- Unequal -4.5498 100.6 0.0001 Equal -3.8914 106.0 0.0002 For H0: Variances are equal, F' = 4.54 DF = (66,40) Prob>F' = 0.0000 SAS システム 5 21:26 Wednesday, December 21, 2005 TTEST PROCEDURE Variable: KODUKAI SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 105 49238.09523810 45543.57039176 4444.59736677 M 210 47852.38095238 50103.26292794 3457.45361572 Variances T DF Prob>|T| --------------------------------------- Unequal 0.2461 226.7 0.8058 Equal 0.2384 313.0 0.8117 For H0: Variances are equal, F' = 1.21 DF = (209,104) Prob>F' = 0.2753
/* Lesson 11-3 */ /* File Name = les1103.sas 12/22/05 */ data gakusei; infile 'all05be.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:26 Wednesday, December 21, 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 108 6903.5000 17712.0 803.510230 63.921296 M 219 46724.5000 35916.0 803.510230 213.353881 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 3 21:26 Wednesday, December 21, 2005 N P A R 1 W A Y P R O C E D U R E S = 6903.50 Z = -13.4510 Prob > |Z| = 0.0001 T-Test Approx. Significance = 0.0001 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 180.95 DF = 1 Prob > CHISQ = 0.0001 SAS システム 4 21:26 Wednesday, December 21, 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 77 3782.5000 11434.5000 645.450003 49.123377 M 219 40173.5000 32521.5000 645.450003 183.440639 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 5 21:26 Wednesday, December 21, 2005 N P A R 1 W A Y P R O C E D U R E S = 3782.50 Z = -11.8545 Prob > |Z| = 0.0001 T-Test Approx. Significance = 0.0001 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 140.55 DF = 1 Prob > CHISQ = 0.0001 SAS システム 6 21:26 Wednesday, December 21, 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 41 1493.50000 2234.50000 157.094830 36.4268293 M 67 4392.50000 3651.50000 157.094830 65.5597015 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 7 21:26 Wednesday, December 21, 2005 N P A R 1 W A Y P R O C E D U R E S = 1493.50 Z = -4.71371 Prob > |Z| = 0.0001 T-Test Approx. Significance = 0.0001 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 22.249 DF = 1 Prob > CHISQ = 0.0001 SAS システム 8 21:26 Wednesday, December 21, 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 105 17613.0 16590.0 758.145796 167.742857 M 210 32157.0 33180.0 758.145796 153.128571 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 9 21:26 Wednesday, December 21, 2005 N P A R 1 W A Y P R O C E D U R E S = 17613.0 Z = 1.34869 Prob > |Z| = 0.1774 T-Test Approx. Significance = 0.1784 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 1.8207 DF = 1 Prob > CHISQ = 0.1772
/* Lesson 11-4 */ /* File Name = les1104.sas 12/22/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:26 Wednesday, December 21, 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:26 Wednesday, December 21, 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:26 Wednesday, December 21, 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:26 Wednesday, December 21, 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; ...
[比較演算子]
[論理演算子]
data gakusei; infile 'all05a.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;プログラム例 : les1105.sas、 出力結果 : les1105.lst
[乱数関数] : 乱数を生成する関数