Hello, I need to perform 2-way ANOVA with and without interaction. I am wondering if the code below is correct? Variable 'sex' can be a 1 or 2, variable 'agegrp' can be a 1, 2, or 3, and variable peri is a continuous variable that is a measurement. I need to interpret the coefficient for sex in the one without interaction, and then determine whether agegrp is an effect modifier. Code and output are below. Any and all advice is appreciated!! I'm not sure if I have this setup correctly or not.
CODE:
/*Two way ANOVA by age group and sex with no interaction term. Save the predicted values into a data set called out1*/
proc glm data=bone;
class sex agegrp;
model peri = sex agegrp;
output out=out1;
run;
proc print data=out1;
run;
/*Two way ANOVA by age group and sex with interaction. Save the predicted values into a data set called out2*/
proc glm data=bone;
class sex agegrp;
model peri = sex agegrp sex*agegrp;
estimate 'gender: age group = < 12' sex 1 -1 agegrp*sex 1 0 0 -1 0 0;
estimate 'gender: age group = between 12 and 20' sex 1 -1 agegrp*sex 0 1 0 0 -1 0;
estimate 'gender: age group = 20 and older' sex 1 -1 agegrp*sex 0 0 1 0 0 -1;
output out=out2;
run;
OUTPUT -without interaction:
The GLM Procedure
Dependent Variable: peri
Model | 3 | 38215.08431 | 12738.36144 | 311.43 | <.0001 |
---|---|---|---|---|---|
Error | 661 | 27036.95555 | 40.90311 | ||
Corrected Total | 664 | 65252.03987 |
0.585653 | 10.10223 | 6.395554 | 63.30836 |
sex | 1 | 2846.67657 | 2846.67657 | 69.60 | <.0001 |
---|---|---|---|---|---|
agegrp | 2 | 35368.40774 | 17684.20387 | 432.34 | <.0001 |
sex | 1 | 2377.64138 | 2377.64138 | 58.13 | <.0001 |
---|---|---|---|---|---|
agegrp | 2 | 35368.40774 | 17684.20387 | 432.34 | <.0001 |
OUTPUT - with interaction:
Dependent Variable: peri
Model | 5 | 39885.94536 | 7977.18907 | 207.24 | <.0001 |
---|---|---|---|---|---|
Error | 659 | 25366.09451 | 38.49180 | ||
Corrected Total | 664 | 65252.03987 |
0.611260 | 9.799932 | 6.204176 | 63.30836 |
sex | 1 | 2846.67657 | 2846.67657 | 73.96 | <.0001 |
---|---|---|---|---|---|
agegrp | 2 | 35368.40774 | 17684.20387 | 459.43 | <.0001 |
sex*agegrp | 2 | 1670.86105 | 835.43052 | 21.70 | <.0001 |
sex | 1 | 3354.12307 | 3354.12307 | 87.14 | <.0001 |
---|---|---|---|---|---|
agegrp | 2 | 36322.30089 | 18161.15045 | 471.82 | <.0001 |
sex*agegrp | 2 | 1670.86105 | 835.43052 | 21.70 | <.0001 |
gender: age group = < 12 | 0.56899907 | 0.70119138 | 0.81 | 0.4174 |
---|---|---|---|---|
gender: age group = between 12 and 20 | 5.88697422 | 0.79962957 | 7.36 | <.0001 |
gender: age group = 20 and older | 8.49302897 | 1.19728344 | 7.09 | <.0001 |
Hi. What is the intended purpose of your ESTIMATE statements? - PG
I need to interpret the coefficient for sex in the one without interaction, and then determine whether agegrp is an effect modifier.
You don't ask SAS to compute the coefficients. You can't interpret them unless you have SAS compute them.
Also, I am not familiar with the phrase "effect modifier". Does that mean "interaction is statistically significant"?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.