SAS Tutorials Home

 

SAS Tutorials
Tutorial Home

 

 

 

Simple Repeated Measures ANOVA
using SAS PROC ANOVA & PROC GLM

See www.stattutorials.com/SASDATA for files mentioned in this tutorial, © TexaSoft, 2007

 

These SAS statistics tutorials briefly explain the use and interpretation of standard statistical analysis techniques for Medical, Pharmaceutical, Clinical Trials, Marketing or Scientific Research. The examples include how-to instructions for SAS Software.

Repeated Measures Analysis using PROC ANOVA

 

Repeated Measures are observations taken from the same or related subjects over time or in differing circumstances. Examples would be weight loss or reaction to a drug over time. When there are two repeated measures, the analysis of the data becomes a paired t-test (as discussed earlier). When there are three or more repeated measures, the analysis is a repeated measures analysis of variance. As in the Independent GROUPS ANOVA procedure, you will usually perform the analysis in two steps. First an analysis of variance will determine if there is a difference in means across time. If a difference is evident, then multiple comparisons may be performed to determine where the differences lie.

 

NOTE: This analysis is also called a within-subjects or treatment-by-subject design. Some call it a “Single-factor experiment having repeated measures on the same element.”

 

 

Note:

A repeated measures analysis may be performed using PROC ANOVA, PROC GLM, or PROC MIXED. In this discussion, PROC GLM will be used. The syntax used for the other procedures is similar, but each procedure offers a different set of options and capabilities. There are also a number of other Repeated Measures that will discussed in a different tutorial.

 

 

The hypotheses being tested with a repeated measures ANOVA is:

 

Ho: There is no difference among means of the groups  (repeated measures).

Ha: There is a difference among means of the groups.

 

The data in the following example are repeated measures of reaction times of five persons after being treated with four drugs in randomized order. (This type of data may come from a crossover experimental design.) The data are as follows:

 

Subj  Drug1 Drug2 Drug3 Drug4

1     31    29    17    35

2     15    17    11    23

3     25    21    19    31

4     35    35    21    45

5     27    27    15    31

 

If you data are in this form, you must first restructure the data into this format:

 

      Subj Drug  Time

      1     1     31

      1     2     29

      1     3     17

      etc. . .

      5     1     7

      5     2     27

      5     3     15   

      5     4     31

 

The following code restructures the data into the format needed for the analysis. Note that the DRUG variable here goes from 1 to 4 “DO DRUG =1 to 4;” representing the number of repeated measures in the data.

 

DATA STUDY;

      SUBJ+1;

      DO DRUG =1 to 4;

      INPUT OBS @;

            OUTPUT;

            END;

DATALINES;

31 29 17 35

15 17 11 23

25 21 19 31

35 35 21 45

27 27 15 31

;

This program creates a data set called  STUDY whose data values are in the form of the second table above. To perform a One-way ANOVA, add the following lines to this code: (PROCGLM2.SAS)

 

PROC GLM DATA=STUDY;

       CLASS SUBJ DRUG;

       MODEL OBS= SUBJ DRUG;

       MEANS DRUG/TUKEY;

             TITLE 'Repeated Measures ANOVA;

RUN;

 

The (partial) output for this analysis follows:

                                                            

Source

DF

Sum of Squares

Mean Square

F Value

Pr > F

Model

7

1331.800000

190.257143

25.03

<.0001

Error

12

91.200000

7.600000

 

 

Corrected Total

19

1423.000000

 

 

 

 

 

R-Square

Coeff Var

Root MSE

OBS Mean

0.935910

10.81102

2.756810

25.50000

 

 

 

Source

DF

Type III SSu

Mean Square

F Value

Pr > F

SUBJ

4

648.0000000

162.0000000

21.32

<.0001

DRUG

3

683.8000000

227.9333333

29.99

<.0001

 

 

 

u TheType III SS” analysis of variance table (DRUG line,) reports a p-value of p < 0.0001. This gives evidence to reject the null hypothesis that there is no difference in the drugs.  Since there is a difference in drugs, a multiple comparison test is performed. The results of that test age presented in the next few tables:

 

 

Alpha

0.05

Error Degrees of Freedom

12

Error Mean Square

7.6

Critical Value of Studentized Range

4.19852

Minimum Significant Difference

5.1763

 


 

 

Means with the same letter are not significantly different. v

Tukey Grouping

Mean

N

DRUG

A

33.000

5

4

 

 

 

 

B

26.600

5

1

B

 

 

 

B

25.800

5

2

 

 

 

 

C

16.600

5

3

 

v The Tukey multiple comparison test for DRUGS indicates that the time to relief for DRUG 3 is significantly lower than for all other drugs. There is no statistical difference between drugs 2 and 1, and DRUG 4 has the highest time to relief for all drugs tested.

 

ALTERNATIVE METHOD: If your data are already in the form of the second table above, your code would be as follows (PROCGLM2a.SAS). The results are the same.

 

DATA STUDY;

INPUT SUBJ DRUG OBS;

DATALINES;

1      1      31

1      2      29

1      3      17

1      4      35

2      1      15

…etc

5      3      15

5      4      31

;

run;

ODS RTF; ODS GRAPHICS ON;

PROC GLM DATA=STUDY;

       CLASS SUBJ DRUG;

       MODEL OBS= SUBJ DRUG;

       MEANS DRUG/TUKEY;

       TITLE 'Repeated Measures ANOVA’;

RUN;

ODS RTF CLOSE; ODS GRAPHICS OFF;

 

This discussion only covered the case of a “one-way repeated measures analysis.” There are a number of more complex repeated measures analysis of variance designs that will be discussed later.

 

End of tutorial

See http://www.stattutorials.com/SAS

 

 

New
Quick Reference Guide for SAS
BeSmartNotes (tm)

Click for more info
 or to Order

 

For quick and simple statistical analysis use WINKS SDA


Click for more info

 

Get the SAS BeSmartNotes Quick Reference Guide

Order


| Send comments | Back to Tutorial Menu | TexaSoft |

© Copyright TexaSoft, 1996-2007

This site is not affiliated with SAS(r) or SAS Institute