Help using Base SAS procedures

Can't Figure Out Repeated Measures ANOVA Syntax

Reply
Occasional Contributor
Posts: 16

Can't Figure Out Repeated Measures ANOVA Syntax

Hi SAS Community!

I have done a fair bit of macro programming with SAS and lots of straight-forward analyses, but nothing complex and now I am a overwhelmed. Perhaps you can help? I have an experimental design:

* Treatments: A, B, Sham
* Parameters: just one
* Measurements: baseline, T1 - T4

-> so one parameter measured before and then four times after each intervention

Each subject was exposed to all three treatments (different days) so the treatments and the measurements are repeated. (If that's the correct way to say it).

I want to know whether treatment modulates the parameter and how it relates to time, so I thought a two-way repeated measures ANOVA would do be a nice start, followed by Tukey post-hoc test to see if A and B are dif from each other, or just sham. I suppose I could use Dennet post hoc test instead since sham is involved.

I may also want to do a separate model with an interaction term.

What would be the complete SAS syntax for this? I can structure the data as needed (e.g. wide or stacked) but right now I have it like this:

SubjectID Intervention Timepoint Value
===============================
1 A Base 8
1 A T1 19
1 A T2 12
1 A T3 19
1 A T4 13
1 B Base 13
1 B T1 19
1 B T2 11
1 B T3 10
1 B T4 9
1 Sham Base 2
1 Sham T1 3
1 Sham T2 5
1 Sham T3 3
1 Sham T4 4
2 A Base
...
etc.

I was thinking something like

proc glm
class intervention timepoint;
model value = intervention timepoint;
means group / cldiff tukey;
run;

But this is not repeated measures. And I don't even know if this is right. Can you please advise? I can restructure the data however needed, the main thing is I need to do two-way repeated measure anova on the given experiment design.
Thanks!
-Bob Message was edited by: Bob291032
Contributor
Posts: 58

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
This page is helpful and should answer your questions, but your code is missing a REPEATED statement:

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glm_sect036....

Regards,
Mark
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Thank you for replying, but that doesn't really address my questions:

What do you think about using a two-way repeated measures ANOVA for the scenario I outlined? I had heard some discussion of using mixed effects models but it was over my head.

What is the syntax for a two-way repeated measures ANOVA? I've ran the code for one-way but I am confused how to to two way. For instance, do I want something like:

Base T1 T2 T3 T4 = intervention

OR

Value = intervention time

Thanks.
-Bob
Valued Guide
Valued Guide
Posts: 684

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
The topic of repeated measures is large and complex, and I don't think the discussion forum can really address all the issues that you need to consider (since you admit that you don't know too much about the subject). The approach to repeated measures in GLM is very different from the mixed-model approach (such as in MIXED or GLIMMIX, or even GENMOD). I recommend you read:
http://www.ats.ucla.edu/stat/sas/library/mixedglm.pdf
by Russ Wolfinger and co-author. It is now somewhat out of date (lots of new features in MIXED, etc.), but this may get you started.
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Thanks, LVM. Furtonately, I am working with a post-doc who has deeper understanding of the statistics, I am just doing the programming in SAS and she can help me interpret it all. But you're right, I should narrow this down: what is the syntax for a standard two-way repeated measures ANOVA given the vars named above?
Valued Guide
Valued Guide
Posts: 684

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
The article I mentioned gives all the coding for repeated measures using GLM or MIXED.
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

EDIT: Missed the PDF, though it was the SAS doc. I will review the PDF and post back.
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
So I read the paper and was able to generate repeated measures anova using the following code:

title 'Treatment A v. Sham';
proc glm data=expdata;
class intervention;
model base T1 T2 T3 T4 = intervention / nouni;
repeated timepoint 5;
where intervention IN ( 0 1 );
run;

I'm still playing with this, but now I feel like I am in the movie Inception... We need to go deeper! Next thing is to get tukey post-hoc tests to see which timepoints are significant compared to baseline.
Frequent Contributor
Posts: 77

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
Hi Bob,

From your code I see you chose to do the multivariate analysis. I am not very familiar with proc glm usage for the repeated measurements analysis and was wondering how did you account for the fact that all treatments were tested on the same individual (individual is a blocking factor in your design). In proc mixed I would probably include random SubjectID; statement.
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to statsplank
Hi statsplank,

Good question, can you demonstrate that with proc mixed code? One thing that concerned me with the proc glm was that the sphericity test was significant, indicating my data did not have type h variance-covariance matrix. Seeing how you would do this setup with proc mixed would be very helpful, thank you.

-B.
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
I've also tried with PROC MIXED. I had to restructure the data into a long form (each row represents one measurement of one experiment i.e.

subjectID | value | intervention | time
==========================
1 12 A Base
1 10 A T1
1 13 A T2
...
20 15 S T4

proc mixed;
class intervention time;
model value = time intervention time*intervention;
random int / subject = subjectID type=CS;

where ( intervention = 0 OR intervention = 1 );
run;

Does this properly take into consideration that the same subject is going through each intervention AND timepoint? i.e. is this an appropriate way to model the repeated-measures problem in the OP? Statsplank sounds like you think my previous proc GLM attempt was faulty.
Frequent Contributor
Posts: 77

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
Hi Bob,

Given the "long" data set with one record per outcome value, I would try to run the proc mixed as follows:

proc mixed;
class intervention time;
model value = time intervention time*intervention;
repeated time / subject=subjectID type=AR(1);
random int / subject=subjectID;
run;

I put type=AR(1) since you have sequential time points. You may want to specify different covariance structure.
Frequent Contributor
Posts: 77

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
Hi Bob,

In your design, are Base, T1-T4 the same time points for treatments A, B, and Sham? Or the times are treatment specific (15 different time points):

Base_a
Base_b
Base_sham
T1_a
T1_b
T1_sham
T2_a
T2_b
T2_sham
... Message was edited by: statsplank
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to statsplank
Hi statsplank,

Subjects were brought back three separate days, each day receiving a different treatment and having each day their measurements were taken at baseline, t1-t4. So I think the answer to your question is 'yes'. Every subject has five measures for treatment a on day 1, five for treatment b on day 2,and five on day3 for sham. Thank you for helping me!

-Bob
Occasional Contributor
Posts: 16

Re: Can't Figure Out Repeated Measures ANOVA Syntax

Posted in reply to Bob291032
Also, I may be doing something wrong with the ANOVA - it says that the intervention is not significant but the timepoint is! I ran within-intervention paired t-tests comparing the measured value at any given timepoint v. baseline (i.e. what I would want a post-hoc test to do after anova) and I had the expected results: for each of my parameters, intervention A shows a significant change at each time point following baseline, intervention B and Sham do not (i.e. A has a significant effect). Obviously I can't just do 20+ paired t-tests without severe multiple testing type i errors but my point is that all parameters are significantly changed from baseline in the same direction for all time points for intervention A but not for sham or intervention B so a proper anova would have to show a significant treatment effect, yet I am not getting that. I am obviously doing something wrong with the repeated measures ANOVA.

I could really use some expertise on the syntax of a repeated measures ANOVA (each subject repeated for each time point for each intervention) given my problem description. Thanks!
Ask a Question
Discussion stats
  • 14 replies
  • 2353 views
  • 0 likes
  • 4 in conversation