1.data sasuser.score;
input name $ sex $ math chinese english; cards;
Alice f 90 85 91 Tom m 95 87 84 Jenny f 93 90 83 Mike m 80 85 80 Fred m 84 85 89 Kate f 97 83 82 Alex m 92 90 91 Cook m 75 78 76 Bennie f 82 79 84 Hellen f 85 74 84 Wincelet f 90 82 87 Butt m 77 81 79 Geoge m 86 85 82 Tod m 89 84 84 Chris f 89 84 87 Janet f 86 65 67 ; run;
proc tabulate; class sex;
var math chinese english;
table sex all,(math chinese english)*(mean std n); keylabel mean='平均值' std='标准差' n='人数'; run; proc gchart;
hbar sex/sumvar=math; run;
proc sort;by sex;run; proc univariate normal; var math;by sex;run; proc ttest;class sex; var math;run;
proc princomp out=prin n=2 Standard; var math chinese english; proc sort data=prin; by descending prin1; run;
proc factor data=sasuser.score r=v n=2 out=a;
run;
proc sort data=a; by descending factor1;
run;
proc print data=a; run;
分析结果:(2)由 The TTEST Procedure中的Equality of Variances里面F=0.2994再由T-Tests的第一行t
绝对值为0.1815,接受原假设,即男女生人数没有显著性差异。(3)由Eigenvectors的结果知:prin1=0.478043math+0.620716chinese+0.621439english;
Prin2=0.878329math-0.340800chinese-0.335252english;由表达式我们可将prin1看做反应总成绩的指标;将prin2看做反应数学成绩的指标。
标号9 Tod m 89 84 84 0.29720
(4) 由输出结果知:math=0.21843factor1+0.97585factor2;
Chinese=0.90669factor1+0.20054factor2;English=0.90524factor1+0.20506factor2; 由标准因子结果知:分函数为:factor1=-0.2414811math+0.5824678chinese+0.57955006english; Factor2=1.0787857math-0.1330474chinese-0.1270475english;
我们可将factor1看做反应文科类成绩的指标;将factor2看做反应理科类成绩的指标。
序号9的观测向量:
9 Geoge m 86 85 82 0.17710 -0.18504
2.
data kuangwu;
input type cu ag bi@@; cards;
1 2.58 0.90 0.95 1 2.90 1.23 1.00 1 3.55 1.15 1.00 1 2.35 1.15 0.79 1 3.54 1.85 0.79 1 2.70 2.23 1.30 1 2.70 1.70 0.48 0 2.25 1.98 1.06 0 2.16 1.80 1.06 0 2.33 1.74 1.10 0 1.96 1.48 1.04 0 1.94 1.40 1.00 0 3.00 1.30 1.00 0 2.78 1.70 1.48 . 2.95 2.15 1.54 ;
proc discrim simple wcov distance list; class type; var cu ag bi;run;
proc discrim pool=test slpool=0.05 list; class type;
priors '1'=0.5 '0'=0.5;run;
proc discrim method=npar k=2 list; class type;run;
分析输出结果:得type=0的判别函数为:-28.73747+10.31393cu+8.99040ag+16.85778
Type=1的判别函数为:-31.11050+13.78951cu+8.21204ag+11.331.9bi; 知检验矿应归为type=0;即无矿类。
3.
data dantou;
input number x1-x7@@; cards;
1 0.05798 5.5150 347.10 21.910 8586 1742 61.69 2 0.08441 3.9700 347.20 19.710 7947 2000 2440.00 3 0.07217 1.1530 54.85 3.052 3860 1445 9497.00 4 0.15010 1.7020 307.50 15.030 12290 1461 6380.00 5 5.74400 2.8540 229.60 9.657 8099 1266 12520.0 6 0.21300 0.7058 240.30 13.910 8980 2820 4135.00 ;
proc cluster data=dantou method=med outtree=out1 p=7 std pseudo rsq; var x1-x7; id number;run;
proc tree data=out1 horizontal graphics;id number;run;
proc cluster data=dantou method=ave outtree=out2 p=7 std pseudo rsq; var x1-x7; id number;run;
proc cluster data=dantou method=cen outtree=out3 p=7 std pseudo rsq; id number;run;
proc tree data=out3 horizontal graphics;id number;run;
proc cluster data=dantou method=ward outtree=out4 p=7 std pseudo; var x1-x7; id number;run;
proc tree data=out4 n=5 out=out5 horizontal graphics; copy x1-x7; id number;run;
proc sort data=out5 out=out5;by descending cluster;run;
proc print data=out5(keep=number cluster);by descending cluster;id number;run;
proc means data=out5 mean;by descending cluster;id number;run; proc cluster data=dantou method=fle outtree=out6 p=7 beta=-0.25 std pseudo rsq; var x1-x7; id number;run;
proc tree data=out6 n=6 out=out7 horizontal graphics; copy x1-x7; id number;run;
proc sort data=out7 out=out7;by descending cluster;run; proc print data=out7(keep=number cluster); by descending cluster;id number;run;