options ls=80 nodate;

data fert;
input fert $ yield @@;
x1=(fert=
'a'); x2=(fert='b'); x3=(fert='c'); x4=(fert='d');
cards;
a 60 a 61 a 59 a 60 a 60
b 62 b 61 b 60 b 62 b 60
c 63 c 61 c 61 c 64 c 66
d 62 d 61 d 63 d 60 d 64
;

proc print;
title 'fertizer data set';
run;

/* Using GLM, just like we did back in Chapter 2, to fit the ANOVA */

proc glm;
class fert;
model yield=fert/solution;
title 'class statement in GLM';
run;

/* Regressing $Y$ on x1, x2, x3. This is essentially what SAS does when it
fits the ANOVA model using GLM (i.e., it throws out the last column of X). */

proc glm;
model yield = x1 x2 x3;
title 'creating your own dummy variables';
run;

/* Regressing $Y$ on x1, x2, x3, and x4. This gives the overparameterised effects model
SAS uses the side condition tau_4=0 to solve the normal equations. */

proc glm;
model yield = x1 x2 x3 x4;
title 'creating your own dummy variables';
run;