ods html; /* IF there is no significant interaction effect */ data display; input height $ width $ sale @@ ; cards; Bottom Regular 47 Bottom Regular 43 Bottom Wide 46 Bottom Wide 40 Middle Regular 62 Middle Regular 68 Middle Wide 67 Middle Wide 71 Top Regular 41 Top Regular 39 Top Wide 42 Top Wide 46 ; proc glm data=display; class height width; model sale = height width height*width; lsmeans height / stderr pdiff adjust=tukey; lsmeans width / stderr pdiff adjust=tukey; contrast "regular vs wide" width -1 1; contrast "middle vs the others" height 0.5 -1 0.5; run; proc glm data=display; class height width; model sale = height width ; lsmeans height / stderr pdiff adjust=tukey; lsmeans width / stderr pdiff adjust=tukey; contrast "regular vs wide" width -1 1; contrast "middle vs the others" height 0.5 -1 0.5; run; /*Interaction Plot - Method 1.*/ proc sort data=display; by height width; run; proc means data=display noprint; by height width; var sale; output out=means mean=meany; /*Cell means*/ run; symbol1 v = r i = join c = black; symbol2 v = w i = join c = blue; proc gplot data=means; plot meany*height=width; run; /* Data Detergent -- Two factors */ data detergent; input brand $ temp $ dirt ; cards; Super Cold 4 Super Cold 5 Super Cold 6 Super Cold 5 Super Warm 7 Super Warm 9 Super Warm 8 Super Warm 12 Super Hot 10 Super Hot 12 Super Hot 11 Super Hot 9 Best Cold 6 Best Cold 6 Best Cold 4 Best Cold 4 Best Warm 13 Best Warm 15 Best Warm 12 Best Warm 12 Best Hot 12 Best Hot 13 Best Hot 10 Best Hot 13 ; /* run full model with interaction effect */ proc glm data = detergent; class brand temp; model dirt = brand temp brand*temp; run; /* IF the interaction effect is significant */ proc glm data=detergent; class brand temp; model dirt = brand temp brand*temp; lsmeans brand*temp / pdiff stderr adjust=TUKEY; run; /* Interaction Plot - Method 2.*/ proc glm data=detergent; class brand temp; model dirt = brand | temp; /* full model including all interactions*/ lsmeans brand * temp / out=lsm; contrast "Cold vs Hot&Warm by Best vs Super" brand*temp 1 -0.5 -0.5 -1 0.5 0.5; output out=diag p=py r=ry; /* p=predicted value, r=residual */ run; proc print data=lsm; run; symbol1 v = b i = join c = black; symbol2 v = s i = join c = blue; proc gplot data=lsm; /* Interaction Plot */ plot lsmean*temp=brand; /* cell mean vs temp by brand */ run; proc plot data=diag; /* Diagnostic Plots */ plot dirt*py; /* observed v. predicted */ plot py*ry; run; proc univariate data=diag normal; var ry; qqplot; run; ods html close;