Data from Chapter 2 from Table 2.2, page 22
data table2_2; input a score; datalines; 1 16 1 18 1 10 1 12 1 19 2 4 2 7 2 8 2 10 2 1 3 2 3 10 3 9 3 13 3 11 ; run;
Table 4.4, page 70. Orthogonal contrasts in a one-way analysis of variance
NOTE1: Contrasts in SAS are performed through the contrast statement.
NOTE2: The orthogonal contrast exclusively partitions the model sums of squares between the two comparisons (i.e., the sum of the contrast sums of squares equals the sum of squares for the
model).
proc glm data = table2_2; class a; model score = a/ ss3; contrast 'comp1' a 0 1 -1; contrast 'comp2' a 1 -.5 -.5; run; quit;
The GLM Procedure Class Level Information Class Levels Values a 3 1 2 3 Number of observations 15
Dependent Variable: score
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 2 210.0000000 105.0000000 7.00 0.0097
Error 12 180.0000000 15.0000000
Corrected Total 14 390.0000000
R-Square Coeff Var Root MSE score Mean
0.538462 38.72983 3.872983 10.00000
Source DF Type III SS Mean Square F Value Pr > F
a 2 210.0000000 105.0000000 7.00 0.0097
Contrast DF Contrast SS Mean Square F Value Pr > F
comp1 1 22.5000000 22.5000000 1.50 0.2442
comp2 1 187.5000000 187.5000000 12.50 0.0041
Non-orthogonal contrast in a one-way analysis of variance, top of page 78
NOTE: Unlike the previous orthogonal contrast, a non-orthogonal contrast does
not uniquely partition the model sum of squares.
proc glm data = table2_2; class a; model score = a/ ss3; contrast 'comp1' a 1 -1 0; contrast 'comp2' a 1 0 -1; run; quit;
The GLM Procedure
Class Level Information
Class Levels Values
a 3 1 2 3
Number of observations 15
Dependent Variable: score
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 2 210.0000000 105.0000000 7.00 0.0097
Error 12 180.0000000 15.0000000
Corrected Total 14 390.0000000
R-Square Coeff Var Root MSE score Mean
0.538462 38.72983 3.872983 10.00000
Source DF Type III SS Mean Square F Value Pr > F
a 2 210.0000000 105.0000000 7.00 0.0097
Contrast DF Contrast SS Mean Square F Value Pr > F
comp1 1 202.5000000 202.5000000 13.50 0.0032
comp2 1 90.0000000 90.0000000 6.00 0.0306
