* day_day.sas;
options pageno=1 linesize=80;
goptions reset=all;
title "Two-way ANOVA for day";
title2 "Data from day and Reynolds (2007)";
data day;
input location $ exp $ day;
* Apply transformations here;
y = log10(day);
datalines;
Cool EC 22
Cool EC 20
Cool EC 19
Cool EC 19
Cool AC 65
Cool AC 51
Cool AC 70
Cool AC 78
FB EC 9
FB EC 10
FB EC 10
FB EC 10
FB AC 11
FB AC 10
FB AC 10
FB AC 11
RES EC 15
RES EC 12
RES EC 15
RES EC 11
RES AC 13
RES AC 14
RES AC 14
RES AC 13
;
run;
* Print data set;
proc print data=day;
run;
* Plot means, standard errors, and observations;
proc gplot data=day;
plot y*location = exp / vaxis=axis1 haxis=axis1 legend=legend1;
symbol1 i=std1mjt v=star height=2 width=3;
axis1 label=(height=2) value=(height=2) width=3 major=(width=2) minor=none;
legend1 label=(height=2) value=(height=2);
run;
* Two-way ANOVA with all fixed effects;
proc glm data=day;
class location exp ;
model y = location exp location *exp ;
lsmeans location exp / adjust=tukey cl lines;
output out=resids p=pred r=resid;
run;
* Two-way ANOVA with interaction;
title3 "MODEL WITH INTERACTION - USE THIS OUTPUT IF INTERACTION SIGNIFICANT";
proc glm data=day;
class location exp;
model y = location exp location*exp / ss2;
lsmeans location*exp / slice=exp exp=location;
output out=resids p=pred r=resid;
run;
goptions reset=all;
title "Diagnostic plots to check anova assumptions";
* Plot residuals vs. predicted values;
proc gplot data=resids;
plot resid*pred=1 / vaxis=axis1 haxis=axis1;
symbol1 v=star height=2 width=3;
axis1 label=(height=2) value=(height=2) width=3 major=(width=2) minor=none;run;
* Normal quantile plot of residuals;
proc univariate noprint data=resids;
qqplot resid / normal waxis=3 height=4;
run;
quit;
Greeting All
I run one way-ANOVA and I got the results as showed in the pictures attached, can get a similar result in Two-way ANOVA.
Thanks in advance
I run one way-ANOVA and I got the results as showed in the pictures attached, can get a similar result in Two-way ANOVA.
Yes.
Ok , what’s the code that I need to add?
Thanks
lsmeans location*exp / adjust=tukey cl lines;
Many thanks
I add it and it works perfect
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: