proc glm data = disease;
class drug disease;
model y=drug disease drug*disease;
run;
ANOVA
Getting Started
To demonstrate the various types of sums of squares, we’ll create a data frame called df_disease
taken from the SAS documentation.
The Model
For this example, we’re testing for a significant difference in stem_length
using ANOVA.
Sums of Squares Tables
SAS has four types of sums of squares calculations. To get these calculations, the sum of squares option needs to be added (/ ss1 ss2 ss3 ss4
) to the model statement.
proc glm;
class drug disease;=drug disease drug*disease / ss1 ss2 ss3 ss4;
model y run;
Type I
Type II
Type III
Type IV
Contrasts
To get contrasts in SAS, we use the estimate
statement. For looking at contrast we are going to fit a different model on new data, that doesn’t include an interaction term as it is easier to calculate contrasts without an interaction term. For this dataset we have three different drugs A, C, and E.
proc glm data=testdata;
class drug;
model post = drug pre / solution;
estimate 'C vs A' drug -1 1 0;
estimate 'E vs CA' drug -1 -1 2;
run;
Reference: Sum of squares type I, II, and III