BookmarkSubscribeRSS Feed
samer_badri75
Quartz | Level 8
* 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 

 a.PNGb.PNG

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
samer_badri75
Quartz | Level 8

Ok , what’s the code that I need to add?

Thanks

PaigeMiller
Diamond | Level 26
lsmeans location*exp  / adjust=tukey cl lines;

 

--
Paige Miller
samer_badri75
Quartz | Level 8

Many thanks

I add it and it works perfect 1.PNG

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3202 views
  • 0 likes
  • 2 in conversation