This document provides SAS code to conduct a two-way ANOVA and follow up analyses. It includes code for the full two-way ANOVA model, LSMeans comparisons if there is a significant interaction, LSMeans comparisons if no interaction, and two methods for plotting the interaction.
This document provides SAS code to conduct a two-way ANOVA and follow up analyses. It includes code for the full two-way ANOVA model, LSMeans comparisons if there is a significant interaction, LSMeans comparisons if no interaction, and two methods for plotting the interaction.
This document provides SAS code to conduct a two-way ANOVA and follow up analyses. It includes code for the full two-way ANOVA model, LSMeans comparisons if there is a significant interaction, LSMeans comparisons if no interaction, and two methods for plotting the interaction.
class a b; model y = a b a*b; run; /* IF the interaction effect is significant */ proc glm data=rawdata; class a b; model y = a b a*b; lsmeans a*b / stderr pdiff adjust=tukey; run; /* IF there is no significant interaction effect */ proc glm data=rawdata; class a b; model y = a b a*b; lsmeans a / stderr pdiff adjust=tukey; lsmeans b / stderr pdiff adjust=tukey; run; /*Interaction Plot*/ /* Method 1.*/ proc sort data=rawdata; by a b; run;
proc means data=rawdata noprint; by a b; var y; output out=means mean=meany; /*Cell means*/ run; proc plot data=means; plot meany*a=b; run; /* Method 2.*/ proc glm data=rawdata; class a b; model y = a b; lsmeans a*b / out=lsm; output out=diag p=py r=ry; /* p=predicted value! r=residual */ run; proc plot data=lsm; /* Interaction "lot */ plot lsmean*a=b; /* cell mean v# a by b */ plot lsmean*b=a; /* cell mean v# b by a */ run;