By Scarlett Barge
A two-way Analysis of Variance (ANOVA) is a statistical test used to examine how two categorical independent variables (IVs) affect a quantitative dependent variable (DV). In addition to assessing the individual (main) effects of each independent variable, a two-way ANOVA also allows us to test whether there is an interaction effect between them.
When do we use this test?
A two-way ANOVA is appropriate when:
- The dependent variable (DV) is quantitative (continuous or approximately continuous).
- The two independent variables (IV1 and IV2) are categorical, often referred to as factors.

Like linear regression, the two-way ANOVA relies on three core assumptions:
- Independence
– All observations are independently and identically distributed (i.i.d.). - Normality
– The dependent variable is normally distributed within each group (or approximately so). - Homoscedasticity
– The variance of the dependent variable is constant across all combinations of the independent variables.
What does a two-way ANOVA test do?
A two-way ANOVA evaluates three null hypotheses:
- Main effect of independent variable 1
– There is no difference in the mean of the dependent variable across the levels of the first independent variable. - Main effect of independent variable 2
– There is no difference in the mean of the dependent variable across the levels of the second independent variable. - Interaction effect
– The effect of one independent variable on the dependent variable does not depend on the level of the other independent variable.
Running a Two-Way ANOVA in SAS
In SAS, two-way ANOVA is commonly performed using proc glm or proc anova; if the data being tested is unbalanced, proc glm provides more resources for handling. Within this procedure, the dependent variable (DV) is modeled as a function of both independent variables (IV1 and IV2), as well as their interaction.

- CLASS identifies categorical independent variables.
- The MODEL statement specifies the main effects and the interaction term.
- The IV1*IV2 term tests for interaction effects.
Post Hoc Comparisons
If one or more main effects are statistically significant, you may want to explore which specific group means differ. SAS allows for post hoc testing using Tukey’s Honest Significant Difference (HSD) test:

Tukey’s test controls for multiple comparisons and helps identify which category-level differences are statistically significant. You can also add on CLDIFF to get confidence intervals for each factor difference.
In Summary
A two-way ANOVA is a powerful extension of one-way ANOVA that allows researchers to:
- Test the effects of two categorical factors on a quantitative outcome.
- Detect whether those factors interact in influencing the dependent variable.
- Conduct post hoc comparisons to better understand group differences.
When its assumptions are reasonably satisfied, the two-way ANOVA provides a clear and interpretable framework for analyzing multifactor experimental or observational data, especially when implemented efficiently in SAS.


Leave a Reply