options
ps=60 ls=80
pageno=1 formdlim='_';
data
corn;
input
yield nit $ phos $;
cards;
35
L L
26 L L
25 L L
33 L L
31 L L
39 L H
33 L H
41 L H
31 L H
36 L H
37 H L
27 H L
35 H L
27 H L
34 H L
49 H H
39 H H
39 H H
47 H H
46 H H
;
/*
nit*phos = interaction term
Note: remember that SAS alphabetises H and L; H = 1st factor level
Note: estimate statements here are not needed, because there are only
two levels; the means statement gives us all the information we need. */
proc
glm;
class
nit phos;
model
yield = nit phos nit*phos;
means
nit phos nit*phos/lsd;
estimate
'nit pairwise CI' nit 1
-1;
estimate
'phos pairwise CI' phos 1
-1;
run;
/*
constructing an interaction plot */
proc
glm;
class
nit phos;
model
yield = nit phos nit*phos;
output
out=avgs p=ybar;
run;
proc
gplot data=avgs;
plot
ybar*nit=phos;
symbol1
v=triangle l=1
i=join cv=blue;
symbol2
v=circle l=1
i=join cv=orange;
run;
/* Fitting the no-interaction model for Example 10.1.*/
proc
glm;/* The two-factor ANOVA model is basically just a regression model; here,
we define x1 = indicator for nit; x2 = indicator for phos; and x3 = x1*x2 is
the interaction term. Note that the ANOVA table from this fit is the same as
the one above for the two-factor interaction model. */
proc
reg;/* This will give you the same ANOVA table as the no-interaction model that
includes only nit and phos. */
proc
reg;