sas第五章习题答案

data a;
input gender $ height weight age;
cards;
m 68 155 23
f 61 99 20
f 63 115 21
m 70 205 45
m 69 170 .
f 65 125 30
m 72 220 48
;
run;
proc corr data=a nosimple ;
title 'example of a corr matrix';
var height weight;
partial age;
run;
title;
goption csymbol=red;
symbol1 value=dot ;
symbol2 value=none i=rlclm95;
symbol3 value=none i=rlcli95 line=3;
proc gplot data=a;
title 'regresstion ';
plot weight*height=1
weight*height=2
weight*height=3/overlay;
run;
quit;

/*proc gplot data=a;*/
/*plot height*weight=age;*/
/*run;*/
/**/
data a;
input gender $ height weight age;
height2=height**2;
cards;
m 68 155 23
f 61 99 20
f 63 115 21
m 70 205 45
m 69 170 .
f 65 125 30
m 72 220 48
;
run;
proc reg data=a;
title 'regression of weight by height';
model weight=height height2;
plot weight*height
r.*height;
run;
quit;

data heart;
input dose hr @@;
cards;
2 60 2 58 4 63 4 62 8 67 8 65 16 70 16 70 16 70 32 74 32 73
;
symbol value=dot color=black i=sm;
proc gplot data=heart;
plot hr*dose;
run;
proc reg data=heart;
model hr=dose;
run;

data t_5_1;
input x y z ;
cards;
1 3 15
7 13 7
8 12 5
3 4 14
4 7 10
;
run;
proc corr data=t_5_1;
var x y z;
run;
proc corr data=t_5_1;
var x y;
partial z;
run;
proc corr data=t_5_1;
var x z;
partial y;
run;
data exam;
input (q1-q8)(1.);
sum_exam=sum(of q1-q8);
cards;
10101010
11111111
11110101
01100000
11110001
11111111
11111101
11111101
10110101
00010110
;
run;
proc corr data=exam;
var sum_exam;
with q1--q8;
run;
data t_5_3;
input age sbp;
cards;
15 116
20 120
25 130
30 132
40 150
50 148
;
run;
proc reg data=t_5_3;
model sbp=age;
run;

*** dependence can be explained independence with 90;
data scores;
do subject=1 to 100;
if ranuni(1357) lt .5 then group='a';
else group='b';
math=round(rannor(1357)*20+550+10*(group eq 'a'));
science=round(rannor(1357)*15+.4*math +300);
english=round(rannor(1357)*20+500+.05*science+.05*math);
spelling=round(rannor(1357)*15+.1*english +500);
vocab=round(rannor(1357)*5+400+.1*spelling+.2*english);
physical=round(rannor(1357)*20+550);
overall=round(mean(math,science,english,spelling,vocab,physical));
sum=math+science+english+spelling+vocab+physical;
output;
end;

run;
proc corr data=scores nosimple;
var sum;
with math--physical;
run;
proc corr data=scores nosimple;
var physical;
with math--sum;
run;
proc corr data=scores nosimple;
var overall;
with math--physical;
run;
data t_5_5;
input x y z ;
cards;
1 3 15
7 13 7
8 12 5
3 4 14
4 7 10
;
run;
proc reg data=t_5_5;
model y=x;
run;
data t_5_6;
set scores;
run;
proc reg data=t_5_6;
model science=math;
PLOT r.*math;
run;
symbol value=dot color=red i=rlclm95;
proc gplot data=t_5_6;
PLOT r.*math;
plot science*math;
run;
data t_5_7;
set t_5_5;
lx=log(x);
ly=log(y);
lz=log(z);
run;
proc corr data=t_5_7 ;
var lx ly lz;
run;

相关主题
相关文档
最新文档