How do I perform a Two-Way ANOVA in SAS? 2

How do I perform a Two-Way ANOVA in SAS?

A Two-Way ANOVA (Analysis of Variance) is a statistical method used to analyze the differences between two or more groups while considering the effects of two categorical independent variables. In SAS, performing a Two-Way ANOVA requires the use of the PROC GLM (General Linear Model) procedure. This procedure allows for the examination of main effects and interaction effects between the two independent variables, as well as the overall significance of the model. The output of the analysis includes various statistical measures such as F-values, p-values, and means of each group. By following the appropriate syntax and inputting the necessary data, SAS can efficiently and accurately perform a Two-Way ANOVA, aiding in the interpretation of relationships between variables in a research study or experiment.

Perform a Two-Way ANOVA in SAS


A two-way ANOVA is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups that have been split on two variables (sometimes called “factors”).

This tutorial provides a step-by-step example of how to perform a two-way ANOVA in SAS.

Step 1: Create the Data

Suppose a botanist wants to know whether or not plant growth is influenced by sunlight exposure and watering frequency.

She plants 30 seeds and lets them grow for one month under different conditions for sunlight exposure and watering frequency. After one month, she records the height of each plant. The results are shown below:

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

/*create dataset*/
data my_data;
    input water $ sunlight $ height;
    datalines;
daily low 6
daily low 6
daily low 6
daily low 5
daily low 6
daily med 5
daily med 5
daily med 6
daily med 4
daily med 5
daily high 6
daily high 6
daily high 7
daily high 8
daily high 7
weekly low 3
weekly low 4
weekly low 4
weekly low 4
weekly low 5
weekly med 4
weekly med 4
weekly med 4
weekly med 4
weekly med 4
weekly high 5
weekly high 6
weekly high 6
weekly high 7
weekly high 8
;run;

Step 2: Perform the Two-Way ANOVA

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

/*perform two-way ANOVA*/
proc ANOVAdata=my_data;
class water sunlight;
model height = water sunlight water*sunlight;
means water sunlight / tukeycldiff;
run;

Step 3: Interpret the Results

The first table we want to analyze in the results is the ANOVA table:

two-way ANOVA in SAS

From this table we can see:

  • The p-value for water: .0005
  • The p-value for sunlight: <.0001
  • The p-value for the interaction between water and sunlight: .1207

This tells us that both water and sunlight are statistically significant predictors of plant height and that there is no statistically significant interaction effect between water and sunlight.

First, we’ll look at the Tukey post-hoc comparisons for water:

From the output we can see that the mean difference in height between plants that were watered daily vs. weekly was 1.0667 inches.

The 95% confidence interval for the difference in mean height is [.5163, 1.6170]. This means we’re 95% confident that the true difference in mean height between plants watered daily and plants watered weekly is between .5163 inches and 1.6170 inches.

First, we’ll look at the Tukey post-hoc comparisons for sunlight:

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 that the following group means are statistically significantly different:

  • High sunlight vs. Low sunlight (95% C.I. = [.8844, 2.5156])
  • High sunlight vs. Medium sunlight (95% C.I. = [1.2844, 2.9156])

Step 4: Report the Results

Lastly, we can of the two-way ANOVA:

A two-way ANOVA was performed to analyze the effect of watering frequency and sunlight exposure on plant growth.

 

A two-way ANOVA revealed that there was not a statistically significant interaction between the effects of watering frequency and sunlight exposure (p = .1207).

 

Simple main effects analysis showed that watering frequency had a statistically significant effect on plant growth (p = .0005).

 

Simple main effects analysis showed that sunlight exposure also had a statistically significant effect on plant growth (p < .0001).

Additional Resources

The following tutorials provide additional information about two-way ANOVAs:

Cite this article

stats writer (2024). How do I perform a Two-Way ANOVA in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-do-i-perform-a-two-way-anova-in-sas/

stats writer. "How do I perform a Two-Way ANOVA in SAS?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-do-i-perform-a-two-way-anova-in-sas/.

stats writer. "How do I perform a Two-Way ANOVA in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-do-i-perform-a-two-way-anova-in-sas/.

stats writer (2024) 'How do I perform a Two-Way ANOVA in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-do-i-perform-a-two-way-anova-in-sas/.

[1] stats writer, "How do I perform a Two-Way ANOVA in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.

stats writer. How do I perform a Two-Way ANOVA in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top