Contributor
Posts: 23

# Two-way ANOVA with and without interaction

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 Error Corrected Total 3 38215.1 12738.36144 311.43 <.0001 661 27037 40.90311 664 65252

 0.585653 10.1022 6.39555 63.3084

 sex agegrp 1 2846.68 2846.68 69.6 <.0001 2 35368.4 17684.2 432.34 <.0001

 sex agegrp 1 2377.64 2377.64 58.13 <.0001 2 35368.4 17684.2 432.34 <.0001

OUTPUT - with interaction:

Dependent Variable: peri

 Model Error Corrected Total 5 39885.9 7977.18907 207.24 <.0001 659 25366.1 38.49180 664 65252

 0.61126 9.79993 6.20418 63.3084

 sex agegrp sex*agegrp 1 2846.68 2846.68 73.96 <.0001 2 35368.4 17684.2 459.43 <.0001 2 1670.86 835.431 21.7 <.0001

 sex agegrp sex*agegrp 1 3354.12 3354.12 87.14 <.0001 2 36322.3 18161.2 471.82 <.0001 2 1670.86 835.431 21.7 <.0001

 gender: age group = < 12 gender: age group = between 12 and 20 gender: age group = 20 and older 0.568999 0.701191 0.81 0.4174 5.88697 0.79963 7.36 <.0001 8.49303 1.19728 7.09 <.0001

Posts: 5,540

## Re: Two-way ANOVA with and without interaction

Hi. What is the intended purpose of your ESTIMATE statements? - PG

PG
Posts: 3,058

## Re: Two-way ANOVA with and without interaction

```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"?

--
Paige Miller
Discussion stats
• 2 replies
• 237 views
• 0 likes
• 3 in conversation