This page shows how to obtain the results from Kirk Chapter 5 using SAS.
Use data file cr4, page 167.
data cr4; input y a order; datalines; 4 1 1 6 1 2 3 1 3 3 1 4 1 1 5 3 1 6 2 1 7 2 1 8 4 2 1 5 2 2 4 2 3 3 2 4 2 2 5 3 2 6 4 2 7 3 2 8 5 3 1 6 3 2 5 3 3 4 3 4 3 3 5 4 3 6 3 3 7 4 3 8 3 4 1 5 4 2 6 4 3 5 4 4 6 4 5 7 4 6 8 4 7 10 4 8 ; run;
Table 5.2-1, page 167.
Note: The formchar option defines the characters used for constructing the table outlines.
options formchar='|-*+*+++*+*';
proc tabulate data=cr4;
class order a;
var y;
table order, mean*y=' '*a;
run;
*----------------------+---------------------------------------------------*
| | Mean |
| +---------------------------------------------------+
| | a |
| +------------+------------+------------+------------+
| | 1 | 2 | 3 | 4 |
+----------------------+------------+------------+------------+------------+
|order | | | | |
+----------------------+ | | | |
|1 | 4.00| 4.00| 5.00| 3.00|
+----------------------+------------+------------+------------+------------+
|2 | 6.00| 5.00| 6.00| 5.00|
+----------------------+------------+------------+------------+------------+
|3 | 3.00| 4.00| 5.00| 6.00|
+----------------------+------------+------------+------------+------------+
|4 | 3.00| 3.00| 4.00| 5.00|
+----------------------+------------+------------+------------+------------+
|5 | 1.00| 2.00| 3.00| 6.00|
+----------------------+------------+------------+------------+------------+
|6 | 3.00| 3.00| 4.00| 7.00|
+----------------------+------------+------------+------------+------------+
|7 | 2.00| 4.00| 3.00| 8.00|
+----------------------+------------+------------+------------+------------+
|8 | 2.00| 3.00| 4.00| 10.00|
*----------------------+------------+------------+------------+------------*
proc means mean std data=cr4;
class a;
var y;
run;
The MEANS Procedure
Analysis Variable : y
N
a Obs Mean Std Dev
---------------------------------------------------
1 8 3.0000000 1.5118579
2 8 3.5000000 0.9258201
3 8 4.2500000 1.0350983
4 8 6.2500000 2.1213203
---------------------------------------------------
Table 5.3-2, page 172.
proc glm data=cr4;
class a;
model y = a;
run;
The GLM Procedure
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 3 49.0000000 16.3333333 7.50 0.0008
Error 28 61.0000000 2.1785714
Corrected Total 31 110.0000000
R-Square Coeff Var Root MSE y Mean
0.445455 34.72938 1.475998 4.250000
Source DF Type I SS Mean Square F Value Pr > F
a 3 49.00000000 16.33333333 7.50 0.0008
Source DF Type III SS Mean Square F Value Pr > F
a 3 49.00000000 16.33333333 7.50 0.0008
3 contrasts, page 173.
Note: SAS reports contrasts as F-ratios which equal the t-values squared from the book.
proc glm data=cr4; class a; model y = a; contrast 'c1' a 1 -1 0 0; contrast 'c2' a 0 0 1 -1; contrast 'c3' a 1 1 -1 -1; run; [some output omitted] Contrast DF Contrast SS Mean Square F Value Pr > F c1 1 1.00000000 1.00000000 0.46 0.5036 c2 1 16.00000000 16.00000000 7.34 0.0114 c3 1 32.00000000 32.00000000 14.69 0.0007
Table 5.4-1, page 174.
Note: We will demonstrate pairwise comparisons using the tukey option since SAS does not have Fisher-Hayter comparisons.
proc glm data=cr4;
class a;
model y = a;
means a / tukey;
run;
[some output omitted]
Tukey's Studentized Range (HSD) Test for y
NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher
Type II error rate than REGWQ.
Alpha 0.05
Error Degrees of Freedom 28
Error Mean Square 2.178571
Critical Value of Studentized Range 3.86125
Minimum Significant Difference 2.015
Means with the same letter are not significantly different.
Tukey
Groupi
ng Mean N a
A 6.2500 8 4
A
B A 4.2500 8 3
B
B 3.5000 8 2
B
B 3.0000 8 1
Parts of Table 5.7-4, page 196.
proc glm data=cr4; class a; model y = a; contrast 'linear' a -3 -1 1 3; contrast 'quadratic' a 1 -1 -1 1; contrast 'cubic' a -1 3 -3 1; run; [some output omitted] Contrast DF Contrast SS Mean Square F Value Pr > F linear 1 44.10000000 44.10000000 20.24 0.0001 quadratic 1 4.50000000 4.50000000 2.07 0.1617 cubic 1 0.40000000 0.40000000 0.18 0.6716
