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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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