BookmarkSubscribeRSS Feed
Felix82
Calcite | Level 5

Hey @ all,

for a couple of days now I am trying to code an interaction in my "proc mixed" model but I do not succeed. I searched google and SAS.support page but I am not able to translate those solutions to my problem.


My question:

How do I write the contrast statement If I want to assess the treatment effect from visit 1 to visit 6 taking into account that there is a treatment*visit interaction?

Model:

%macro LMM (Y=, M=);

proc mixed data=work.XXX order=data;

       class treatment visit;

       MODEL &Y = treatment visit treatment*visit &M /solution ddfm=satterth ;

My outcome (y) is the change in a biomarker.

Treatment has two levels (placebo vs. active treatment).

I have baseline and 5 visits (follow up visits).

And a treatment*visit interaction.

I tried different solutions but most of the time they are not estimable.

Example (gives results but must be wrong):

contrast 'XX vs placebo '        treatment 2  -2

                                          visit 0 0 0 0 0 0

                                          treatment*visit      1 0 0 0 0 1

                                                                    -1 0 0 0 0 -1  /divisor=2 cl e;

I hope someone can help me.

Thank you.

Tobias

2 REPLIES 2
Rick_SAS
SAS Super FREQ

You might want to read this paper about the LSMESTIMATE statement, which is newer and easier to use: CONTRAST and ESTIMATE Statements Made Easy: The LSMESTIMATE Statement

SteveDenham
Jade | Level 19

One thing that will help is to get the least squares means for each treatment at each time.  Consider the following code:

proc mixed data=work.XXX order=data;

class treatment visit subjid; /* I include subjid here because of the repeated nature of the design.  The data should be sorted by treatment, subjid, visit */

model &Y= treatment visit treatment*visit &M/solution ddfm=kenwardrogers; /* This assumes that &M is a continuous covariate.  It also shifts to the Kenward-Rogers adjustment, which uses the Satterthwaite degrees of freedom but also applies an appropriate shrinkage due to the repeated measurements */
repeated visit/subject=subjid type=ar(1); /* Sets visit as a repeated factor.  The autoregressive structure assumes equal spacing in time for the visits.  Since they are indexed, this is OK, provided that the visits are very nearly the same time apart */

random intercept/subject=subjid; /* Adds a random effect of subject for autoregressive repeated measures.  See Littell et. al. J. Anim. Sci. 1998. 76:1216–1231 */

lsmeans treatment visit treatment*visit/cl; /* Estimates of means at mean of covariate */

lsmestimate treatment*visit "Treatment1 vs Treatment 2 at visit 1" -1 1  0 0  0 0  0 0  0 0  0 0,

                                        "Treatment 1 vs Treatment 2 at visit 2" 0 0  -1 1  0 0  0 0  0 0  0 0; /* More comparisons can be added.  It is a good idea to use the "comma" method rather than putting each into a separate statement, as you may wish to apply some adjustment for multiple testing as an option */

I hope this gets you started.

Steve Denham

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2584 views
  • 6 likes
  • 3 in conversation