Final-Group Assignment, Presentation, Dr. Dash, 25,11,2010 (0524)
Sas tutorial 0524
-
Upload
wensheng-chang -
Category
Health & Medicine
-
view
1.080 -
download
1
description
Transcript of Sas tutorial 0524
SAS tutorial 0524
proc anova;
class A B S;
model y=S|A|B;
test h=A e= S*A;
run;
The same as glm (但是比較沒用 ...)
Example
title 'Unbalanced Two-Way Analysis of Variance';
data a;
input drug disease @;
do i=1 to 6;
input y @;
output;
end;
datalines;
1 1 42 44 36 13 19 22
1 2 33 . 26 . 33 21
1 3 31 -3 . 25 25 24
2 1 28 . 23 34 42 13
2 2 . 34 33 31 . 36
2 3 3 26 28 32 4 16
3 1 . . 1 29 . 19
3 2 . 11 9 7 1 -6
3 3 21 1 . 9 3 .
4 1 24 . 9 22 -2 15
4 2 27 12 12 -5 16 15
4 3 22 7 25 5 12 .
;
4x3 2-way
code
ods graphics on;
proc glm;
class drug disease;
model y=drug disease drug*disease /ss3;
contrast 'drug 1 vs 2' drug 1 -1 0 0;
contrast 'drug 1 vs 3' drug 1 0 -1 0;
contrast 'drug 1 vs 4' drug 1 0 0 -1;
lsmeans drug/ pdiff=all adjust=tukey;
run;
ods graphics off;
Result
Interaction plot
Dummy variable
• Category variable• Set reference group• Set N-1 d.variables:
– 1 if xij belongs to the group specified
– 0 if xij belongs to other groups
• E.g. variable drug in the example:– 0 0 0 => drug=1– 1 0 0 => drug=2– 0 1 0 => drug=3– 0 0 1 => drug=4
Data
Result (is the same)
Why use d.v. coding?
http://www.sas.com/offices/NA/canada/downloads/presentations/VancouverMay11/Variable.pdf
If you cannot run contrast analysis──
• Check coefficients• Separate main effects and interactions into
different models.• e.g. 2-way ANOVA with interaction:
– model y = A B;(contrasts for main effects)
– model y = A*B;(contrasts for interaction)