/* Lesson 09-1 */ /* File Name = les0901.sas 12/02/04 */ data gakusei; infile 'all04b.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 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=SHINTYOU Normal Probability Plot 172.5+ +*+++* | *******+*+* | **********+ | *********+ | +******** 147.5+*+++*+*+** +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 15 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=TAIJYUU Normal Probability Plot 57.5+ ***+*+*+++* | **********+*+ 47.5+ *********+++ | *+***+****+ 37.5++*+++*++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 22 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=KYOUI Normal Probability Plot 92.5+ ++++*++++ | **********++**+++* 82.5+ ***+*+*+*+*++++ | +++*+*+**++++ 72.5+++++* +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 29 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=F --------------------------------- Univariate Procedure Variable=KODUKAI Normal Probability Plot 325000+ * | | * 175000+ *** ++++ | ******+++++ | +********** 25000+* * ********************* +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 36 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=SHINTYOU Normal Probability Plot 187.5+ ** | ******+***+ | *********+ 172.5+ ************ | *********++ | * ********+ 157.5+*++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 43 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=TAIJYUU Normal Probability Plot 105+ * | * * | ** +++ 75+ *********++++ | *************** | *****************+ 45+**++*+++++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 50 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=KYOUI Normal Probability Plot 115+ * * + | ****+++++++ | ********+***+* 85+ *************++ | +*++***+++++ |++++ 55+ * +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2 SAS システム 57 22:10 Wednesday, December 1, 2004 -------------------------------- SEX=M --------------------------------- Univariate Procedure Variable=KODUKAI Normal Probability Plot 325000+ * | | * 175000+ ***** ***+++ | ******++++++ | ++******+ 25000+** ************************** +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2
/* Lesson 09-2 */ /* File Name = les0902.sas 12/02/04 */ data gakusei; infile 'all04b.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 22:10 Wednesday, December 1, 2004 TTEST PROCEDURE Variable: SHINTYOU SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 101 159.02673267 5.49512313 0.54678519 M 201 172.14477612 5.36345831 0.37830918 Variances T DF Prob>|T| --------------------------------------- Unequal -19.7294 196.2 0.0001 Equal -19.8889 300.0 0.0000 For H0: Variances are equal, F' = 1.05 DF = (100,200) Prob>F' = 0.7645 SAS システム 3 22:10 Wednesday, December 1, 2004 TTEST PROCEDURE Variable: TAIJYUU SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 70 48.53142857 4.80167673 0.57391014 M 201 62.24626866 7.97776275 0.56270800 Variances T DF Prob>|T| --------------------------------------- Unequal -17.0636 201.3 0.0001 Equal -13.5444 269.0 0.0000 For H0: Variances are equal, F' = 2.76 DF = (200,69) Prob>F' = 0.0000 SAS システム 4 22:10 Wednesday, December 1, 2004 TTEST PROCEDURE Variable: KYOUI SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 38 83.18421053 4.05272856 0.65743939 M 64 88.50000000 8.61891607 1.07736451 Variances T DF Prob>|T| --------------------------------------- Unequal -4.2118 96.0 0.0001 Equal -3.5696 100.0 0.0006 For H0: Variances are equal, F' = 4.52 DF = (63,37) Prob>F' = 0.0000 SAS システム 5 22:10 Wednesday, December 1, 2004 TTEST PROCEDURE Variable: KODUKAI SEX N Mean Std Dev Std Error ----------------------------------------------------------------------- F 98 49209.18367347 46883.48815076 4735.94748530 M 192 49187.50000000 50935.09112442 3675.92357149 Variances T DF Prob>|T| --------------------------------------- Unequal 0.0036 210.3 0.9971 Equal 0.0035 288.0 0.9972 For H0: Variances are equal, F' = 1.18 DF = (191,97) Prob>F' = 0.3626
/* Lesson 09-3 */ /* File Name = les0903.sas 12/02/04 */ data gakusei; infile 'all04b.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 22:10 Wednesday, December 1, 2004 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 101 5964.0 15301.5000 715.471173 59.049505 M 201 39789.0 30451.5000 715.471173 197.955224 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 3 22:10 Wednesday, December 1, 2004 N P A R 1 W A Y P R O C E D U R E S = 5964.00 Z = -13.0501 Prob > |Z| = 0.0001 T-Test Approx. Significance = 0.0001 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 170.32 DF = 1 Prob > CHISQ = 0.0001 SAS システム 4 22:10 Wednesday, December 1, 2004 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 70 3096.5000 9520.0 564.205492 44.235714 M 201 33759.5000 27336.0 564.205492 167.957711 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 5 22:10 Wednesday, December 1, 2004 N P A R 1 W A Y P R O C E D U R E S = 3096.50 Z = -11.3842 Prob > |Z| = 0.0001 T-Test Approx. Significance = 0.0001 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 129.62 DF = 1 Prob > CHISQ = 0.0001 SAS システム 6 22:10 Wednesday, December 1, 2004 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 38 1329.0 1957.0 143.753796 34.9736842 M 64 3924.0 3296.0 143.753796 61.3125000 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 7 22:10 Wednesday, December 1, 2004 N P A R 1 W A Y P R O C E D U R E S = 1329.00 Z = -4.36510 Prob > |Z| = 0.0001 T-Test Approx. Significance = 0.0001 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 19.084 DF = 1 Prob > CHISQ = 0.0001 SAS システム 8 22:10 Wednesday, December 1, 2004 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 98 14865.0 14259.0 672.085438 151.683673 M 192 27330.0 27936.0 672.085438 142.343750 Average Scores Were Used for Ties Wilcoxon 2-Sample Test (Normal Approximation) (with Continuity Correction of .5) SAS システム 9 22:10 Wednesday, December 1, 2004 N P A R 1 W A Y P R O C E D U R E S = 14865.0 Z = 0.900927 Prob > |Z| = 0.3676 T-Test Approx. Significance = 0.3684 Kruskal-Wallis Test (Chi-Square Approximation) CHISQ = 0.81301 DF = 1 Prob > CHISQ = 0.3672
/* Lesson 09-4 */ /* File Name = les0904.sas 12/02/04 */ 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 22:10 Wednesday, December 1, 2004 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 22:10 Wednesday, December 1, 2004 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 システム 3 22:10 Wednesday, December 1, 2004 Univariate Procedure Variable=DIF Quantiles(Def=5) 100% Max 0.21 99% 0.21 75% Q3 0.185 95% 0.21 50% Med 0.105 90% 0.21 25% Q1 -0.05 10% -0.32 0% Min -0.32 5% -0.32 1% -0.32 Range 0.53 Q3-Q1 0.235 Mode 0.21 SAS システム 5 22:10 Wednesday, December 1, 2004 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 22:10 Wednesday, December 1, 2004 Univariate Procedure Variable=DIF Normal Probability Plot 0.25+ *++++* | *++*+++ | *++++ -0.05+ *+++*++ | +++++ | ++++++ -0.35+ +++++ * +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2
data seito04; 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; ...
[比較演算子]
[論理演算子]