How to perform Tukey’s Test in SAS

Tukey’s Test in SAS can be performed using the PROC GLM procedure. The TEST statement is used to specify the Tukey’s Test and the output is a table of pairwise comparisons between the groups in the model along with the associated p-values. In order to perform the Tukey’s Test, the variables in the model must be categorical. The PROC GLM output also provides the confidence intervals and the means for each group in the model.


one-way ANOVA is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups.

If the overall p-value from the ANOVA table is less than some significance level, then we have sufficient evidence to say that at least one of the means of the groups is different from the others.

However, this doesn’t tell us which groups are different from each other. It simply tells us that not all of the group means are equal.

In order to find out exactly which groups are different from each other, we must conduct a post hoc test.

One of the most commonly used post hoc tests is Tukey’s Test, which allows us to make pairwise comparisons between the means of each group while controlling for the family-wise error rate.

The following example shows how to perform Tukey’s Test in R.

Example: Tukey’s Test in SAS

Suppose a researcher recruits 30 students to participate in a study. The students are to use one of three studying methods to prepare for an exam.

The exam results for each student are shown below:

We can use the following code to create this dataset in SAS:

/*create dataset*/
data my_data;
    input Method $ Score;
    datalines;
A 78
A 81
A 82
A 82
A 85
A 88
A 88
A 90
B 81
B 83
B 83
B 85
B 86
B 88
B 90
B 91
C 84
C 88
C 88
C 89
C 90
C 93
C 95
C 98
;
run;

Next, we’ll use proc ANOVA to perform the one-way ANOVA:

/*perform one-way ANOVA*/
proc ANOVA data=my_data;
class Method;
model Score = Method;
means Method / tukey cldiff;
run;

Note: We used the means statement along with the tukey and cldiff options to specify that a Tukey post-hoc test should be performed (with confidence intervals) if the overall p-value of the one-way ANOVA is statistically significant.

First, we’ll analyze the ANOVA table in the output:

one-way ANOVA in SAS

  • The overall F Value: 5.26
  • The corresponding p-value: 0.0140

Recall that a one-way ANOVA uses the following null and alternative hypotheses:

  • H0: All group means are equal.
  • HA: At least one group mean is different from the rest.

Since the p-value from the ANOVA table (0.0140) is less than α = .05, we reject the null hypothesis.

This tells us that the mean exam score is not equal between the three studying methods.

Related:

To determine exactly which group means are different, we must refer to the final table in the output that shows the results of the Tukey post-hoc tests:

Tukey's test in SAS

To tell which group means are different, we must look at which pairwise comparisons have stars (***) next to them.

From the table we can see there is a statistically significant difference in mean exam scores between group A and group C.

There are no statistically significant differences between any other group means.

The following tutorials provide additional information about ANOVA models:

A Guide to Using Post Hoc Tests with ANOVA

x