Creation date: 08/03/98

Authored by: Craig Henderson

How do I test contrasts in a repeated measures analysis using SAS or SPSS?

**Answer:**

**In repeated measures analyses, typically, there are
three types of contrasts of interest to the researcher: (a)
polynomial contrasts which tests the polynomial trend in the
data, (b) profile contrasts which test successive pairwise
differences (e.g., mean1 - mean2, mean2-mean3, etc.), and
reference contrasts which compare all means to a specified
reference group (e.g., mean1 - mean2, mean1 - mean3, etc.). In
addition SAS and SPSS allow the researcher to define contrasts of
interest to their specific research design (e.g., mean2 - mean4,
(mean1+mean2)/2 - mean3, etc.).**

**In ****SAS****
release 6.11 or higher:**

```
/* Polynomial
Contrasts */
```

`{Data step};`

PROC GLM DATA={NAME OF YOUR DATA SET};

MODEL {YOUR DV(s)}

REPEATED {YOUR WITHIN SUBJECT EFFECT} POLYNOMIAL;

RUN;

```
/* Profile
Contrasts */
```

`{Data step};`

PROC GLM DATA={NAME OF YOUR DATA SET};

MODEL {YOUR DV(s)}

REPEATED {YOUR WITHIN SUBJECT EFFECT} PROFILE;

RUN;

```
/* Reference
Contrasts */
```

`{Data step};`

PROC GLM DATA={NAME OF YOUR DATA SET};

MODEL {YOUR DV(s)}

REPEATED {YOUR WITHIN SUBJECT EFFECT} CONTRAST (1);

RUN;

```
The contrast (1)
statement assumes that the reference category is the first level
of your repeated measures factor.
```

```
/*
Researcher-Defined Contrasts */
```

```
This involves
setting up a contrast matrix with the MANOVA statement and the
<M = >option. An example is provided in which the second
level of a four level repeated measures factor is contrasted with
the third level:
```

`{Data step};`

MANOVA H=_ALL_ M=(0 1 -1
0) PREFIX=DIFF;

PROC GLM DATA={NAME OF YOUR DATA SET};

MODEL {A B C D}

REPEATED PERIOD;

RUN;

```
The <H =>
option specifies that all effects are to be tested, the <M
=> option defines the effects to be contrasted, and the
<prefix = diff> option supplies a label for this contrast.
For additional contrasts, provide a comma at the end of each line
followed by the next row of the contrast matrix.
```

```
In mixed models
(i.e., models containing one or more within subjects or random
factors and one or more between subjects or fixed factors), the
above syntax would need to be modified with the appropriate CLASS
and MODEL statements.
```

**In ****SPSS****:**

```
****Polynomial
Contrasts
```

`GLM`

{YOUR DV(s)}

/WSFACTOR = {YOUR WITHIN SUBJECTS FACTOR}{NUMBER OF LEVELS OF
YOUR WITHIN SUBJECTS FACTOR} POLYNOMIAL

/METHOD = SSTYPE {YOUR SELECTION}

/CRITERIA = ALPHA(.05)

/WSDESIGN.

```
****Profile
Contrasts
```

`GLM`

{YOUR DV(s)}

/WSFACTOR = {YOUR WITHIN SUBJECTS FACTOR} REPEATED

/METHOD = SSTYPE {YOUR SELECTION}

/CRITERIA = ALPHA(.05)

/WSDESIGN.

```
****Reference
Contrasts
```

`GLM`

{YOUR DV(s)}

/WSFACTOR = {YOUR WITHIN SUBJECTS FACTOR} SIMPLE(1)

/METHOD = SSTYPE {YOUR SELECTION}

/CRITERIA = ALPHA(.05)

/WSDESIGN.

```
The simple (1)
statement assumes that the reference category is the first level
of your repeated measures factor.
```

```
****Researcher-Defined
Contrasts
```

```
This involves
setting up a contrast matrix with the MMATRIX statement. An
example is provided in which the second level of a four level
repeated measures factor is contrasted with the third level:
```

`GLM`

{A B C D}

/WSFACTOR = {PERIOD}

/METHOD = SSTYPE {3}

/CRITERIA = ALPHA(.05)

/WSDESIGN

/MMATRIX B 1 C -1.

```
For additional
contrasts, provide a semicolon at the end of each line followed
by the next contrast.
```

See also:

How to Perform Simple Main Effects Analysis Using SAS or SPSS.

How to Test Contrasts in Simple Mixed Models (One Within Subjects and One Between Subjects Effect). (Under Construction)

*Last updated: 01/18/06 by Craig Henderson*