Tutorials › Biostatistics › SAS PROC MIXED for Repeated Measures

Longitudinal Clinical-Trial Analysis

SAS PROC MIXED for Repeated Measures

A practical guide to analyzing longitudinal and repeated-measures clinical-trial data with SAS PROC MIXED, including fixed effects, covariance structures, REPEATED statements, LS-means, Kenward–Roger degrees of freedom, missing data, model selection, interpretation, and clinical-trial implementation.

Intermediate 22 min read

What You'll Learn

  • Why repeated-measures data require special modeling
  • How PROC MIXED represents longitudinal clinical-trial data
  • How to choose and specify covariance structures
  • How to use LS-means and treatment-by-visit comparisons
  • How PROC MIXED handles unequal numbers of observations and missing data
  • How to build, interpret, and validate a clinical-trial MMRM

Introduction

Clinical trials frequently collect the same outcome repeatedly from each participant.

For example, a clinical trial may measure a patient's blood pressure, symptom score, biomarker concentration, pulmonary function, or disease activity at baseline and at Weeks 2, 4, 8, 12, and 24.

These observations are not independent.

Measurements from the same patient tend to be correlated because they come from the same underlying individual.

This correlation is the defining statistical feature of repeated-measures data.

Key idea: PROC MIXED is particularly useful for longitudinal clinical-trial analyses because it allows the analyst to model the expected mean outcome while also modeling the covariance among repeated observations from the same patient.

Why Ordinary ANOVA Is Not Enough

Suppose 100 patients are randomized to two treatment groups and measured at five post-baseline visits.

The resulting dataset contains approximately:

$$ 100\times5=500 $$

post-baseline observations.

It would be tempting to treat these 500 observations as independent.

That would generally be inappropriate.

The five observations from Patient 001 are related to one another. The five observations from Patient 002 are also related to one another. But Patient 001 and Patient 002 are different individuals.

The correlation structure can therefore be represented conceptually as:

$$ \text{Patient} \rightarrow \text{repeated observations} \rightarrow \text{within-patient correlation} $$

The Longitudinal Data Structure

A typical repeated-measures dataset is stored in long format.

USUBJID Treatment Visit Outcome
001 Drug A Baseline 72
001 Drug A Week 4 65
001 Drug A Week 8 61
001 Drug A Week 12 58
002 Placebo Baseline 70
002 Placebo Week 4 69
002 Placebo Week 8 71
002 Placebo Week 12 70

Each row represents one patient at one measurement occasion.

The patient identifier tells PROC MIXED which observations belong to the same subject.

The Basic Repeated-Measures Model

A simple longitudinal model can be written as:

$$ Y_{ij} = \beta_0 + \beta_1 Treatment_i + \beta_2 Visit_j + \beta_3 Treatment_i\times Visit_j + \epsilon_{ij} $$

where:

  • \(Y_{ij}\) is the outcome for patient \(i\) at visit \(j\)
  • \(\beta_0\) is an intercept
  • \(\beta_1\) represents treatment effects
  • \(\beta_2\) represents visit effects
  • \(\beta_3\) represents the treatment-by-visit interaction
  • \(\epsilon_{ij}\) represents residual variation

The critical additional feature is that the residuals from the same patient are allowed to be correlated.

What PROC MIXED Does

PROC MIXED estimates two broad components:

  1. Fixed effects describing systematic differences in the population mean.
  2. Covariance parameters describing variability and correlation among repeated observations.

This separation is fundamental to understanding PROC MIXED.

Think of the model in two layers: The MODEL statement describes the expected mean response, while the REPEATED statement describes how repeated observations within a patient are correlated.

A First PROC MIXED Example

Suppose the analysis dataset is called analysis and contains:

  • USUBJID — patient identifier
  • TRT01P — treatment group
  • AVISIT — analysis visit
  • AVAL — analysis outcome

A basic repeated-measures model might be:

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model AVAL =
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

run;

This is one of the most important PROC MIXED patterns for clinical programmers to understand.

Breaking Down the PROC MIXED Syntax

The first line invokes PROC MIXED:

proc mixed data=analysis method=reml;

The DATA= option identifies the input dataset.

The METHOD=REML option requests restricted maximum likelihood estimation of the covariance parameters.

REML is commonly used when estimating covariance parameters in linear mixed models.

The CLASS Statement

class USUBJID TRT01P AVISIT;

Categorical variables should generally be included in the CLASS statement.

For example:

Variable Role
USUBJID Subject identifier
TRT01P Treatment group
AVISIT Categorical analysis visit

Whether visit should be modeled categorically or continuously is an important modeling decision.

Categorical Versus Continuous Time

If visit is categorical:

class AVISIT;

model AVAL = TRT01P AVISIT TRT01P*AVISIT / ddfm=kr;

the model estimates a separate mean at each visit.

If time is treated as continuous:

model AVAL = TRT01P WEEK TRT01P*WEEK / ddfm=kr;

the model instead imposes a functional relationship between outcome and time.

Clinical-trial rule of thumb: When the primary objective is to compare treatment groups at specific scheduled visits, treating visit as categorical is often more appropriate than assuming a linear time trend.

The MODEL Statement

The MODEL statement specifies the fixed-effects portion of the model.

model AVAL =
    TRT01P
    AVISIT
    TRT01P*AVISIT
    / ddfm=kr;

This model contains:

  • Overall treatment effect
  • Overall visit effect
  • Treatment-by-visit interaction

The interaction is often particularly important in longitudinal clinical trials.

Why Treatment-by-Visit Matters

Suppose the treatment difference is small at Week 2 but substantial at Week 12.

The treatment effect therefore changes over time.

That pattern is represented by:

$$ Treatment\times Visit $$

Without the interaction, the model imposes a common treatment difference across all visits.

With the interaction, the treatment difference can vary by visit.

Visualizing a Typical Longitudinal Treatment Effect

Figure 1. Simulated Longitudinal Treatment Profiles
Mean outcome profiles for two treatment groups. The example illustrates a treatment difference that becomes larger over time.
Treatment A
Placebo
Estimated mean

Illustrative data only. In an actual clinical trial, estimated means and confidence intervals would be obtained from the fitted model.

The REPEATED Statement

The REPEATED statement tells PROC MIXED how observations within a subject are correlated.

repeated AVISIT /
    subject=USUBJID
    type=un;

This contains three important pieces:

Component Meaning
AVISIT Repeated measurement dimension
SUBJECT=USUBJID Defines the independent clustering unit
TYPE=UN Specifies an unstructured covariance matrix

Why SUBJECT= Matters

Consider this model:

repeated AVISIT / subject=USUBJID type=un;

PROC MIXED understands that the observations for Patient 001 belong together.

The repeated observations for Patient 001 are therefore allowed to have correlation.

Patient 002 has a separate covariance cluster.

Conceptually:

$$ \begin{bmatrix} Y_{i1}\\ Y_{i2}\\ Y_{i3}\\ Y_{i4} \end{bmatrix} \sim N(X_i\beta,\Sigma) $$

where \(\Sigma\) represents the within-patient covariance matrix.

Understanding the Covariance Matrix

Suppose there are four visits.

An unstructured covariance matrix might look like:

$$ \Sigma= \begin{bmatrix} \sigma_1^2 & \sigma_{12} & \sigma_{13} & \sigma_{14}\\ \sigma_{12} & \sigma_2^2 & \sigma_{23} & \sigma_{24}\\ \sigma_{13} & \sigma_{23} & \sigma_3^2 & \sigma_{34}\\ \sigma_{14} & \sigma_{24} & \sigma_{34} & \sigma_4^2 \end{bmatrix} $$

Every variance and covariance is estimated separately.

This is extremely flexible.

But flexibility comes at a cost.

Common Covariance Structures

PROC MIXED provides several covariance structures that are useful for longitudinal analyses.

TYPE= Structure General Interpretation
UN Unstructured Each variance and covariance is estimated separately
CS Compound symmetry Common variance and common covariance
AR(1) First-order autoregressive Correlation decreases as visits become farther apart
TOEP Toeplitz Correlation depends on lag but is not constrained geometrically
VC Variance components Independent residual variances by repeated level under the specified structure

Unstructured Covariance

The most flexible commonly used structure is:

type=un

For \(q\) repeated visits, an unstructured covariance matrix contains:

$$ \frac{q(q+1)}{2} $$

covariance parameters.

For five visits:

$$ \frac{5(5+1)}{2} = 15 $$

parameters are required.

For ten visits:

$$ \frac{10(10+1)}{2} = 55 $$

parameters are required.

Important: An unstructured covariance model can become parameter-heavy as the number of repeated visits increases. Convergence, precision, and sample size should therefore be considered before automatically selecting UN.

Compound Symmetry

Compound symmetry assumes a common variance and a common covariance across visits.

repeated AVISIT /
    subject=USUBJID
    type=cs;

Conceptually:

$$ \Sigma= \begin{bmatrix} \sigma^2 & \sigma_c & \sigma_c\\ \sigma_c & \sigma^2 & \sigma_c\\ \sigma_c & \sigma_c & \sigma^2 \end{bmatrix} $$

This structure is parsimonious but restrictive.

It assumes that the correlation between Week 4 and Week 8 is the same as the correlation between Week 4 and Week 24.

AR(1) Covariance

An autoregressive structure assumes that observations closer together in time are more strongly correlated.

repeated AVISIT /
    subject=USUBJID
    type=ar(1);

The correlation is approximately:

$$ Corr(Y_{ij},Y_{ik}) = \rho^{|j-k|} $$

where \(\rho\) is the lag-one correlation.

Thus:

  • Adjacent visits have correlation \(\rho\)
  • Two visits apart have correlation \(\rho^2\)
  • Three visits apart have correlation \(\rho^3\)
AR(1) is most natural when: The repeated measurements occur at reasonably regular intervals and there is a scientific reason to expect correlation to decrease as temporal separation increases.

Toeplitz Covariance

Toeplitz covariance structures allow the covariance to depend on the lag without requiring the geometric decay imposed by AR(1).

repeated AVISIT /
    subject=USUBJID
    type=toep;

For example, observations one visit apart can share one covariance, observations two visits apart another covariance, and so forth.

This provides more flexibility than CS while potentially using fewer parameters than UN.

Choosing a Covariance Structure

There is no universally correct covariance structure.

Selection should be based on:

  • Study design
  • Number and spacing of visits
  • Scientific plausibility
  • Model convergence
  • Information criteria
  • Prespecified statistical-analysis-plan requirements
  • Interpretability

Comparing Covariance Structures

Suppose the analyst fits:

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model AVAL =
        TRT01P AVISIT TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

run;

and then compares it with:

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model AVAL =
        TRT01P AVISIT TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=ar(1);

run;

The analyst can examine fit statistics such as AIC and BIC.

Criterion General Purpose
AIC Balances model fit against model complexity
AICC Small-sample corrected AIC
BIC Penalizes model complexity more strongly than AIC
Do not select a covariance structure mechanically. A model with a slightly better information criterion is not automatically the best clinical-trial model if it is poorly justified, unstable, or inconsistent with the prespecified analysis.

REML Versus ML

PROC MIXED commonly uses:

method=reml

for estimation of covariance parameters.

REML accounts for the loss of degrees of freedom associated with estimating fixed effects.

Maximum likelihood can be specified using:

method=ml

The distinction becomes particularly important when comparing models with different fixed-effects structures.

Practical rule: REML is commonly preferred for estimating covariance structures when the fixed effects are held constant. ML is generally appropriate when comparing models that differ in their fixed-effects specification using likelihood-based criteria.

Kenward–Roger Degrees of Freedom

A common option in clinical-trial mixed models is:

ddfm=kr

This requests the Kenward–Roger method for denominator degrees of freedom and associated small-sample adjustments.

For example:

model AVAL =
    TRT01P AVISIT TRT01P*AVISIT
    / ddfm=kr;

The method can improve the finite-sample behavior of tests and estimated fixed-effect covariance matrices in mixed models.

Why DDFM Matters

Mixed models do not always have a simple denominator degrees-of-freedom calculation.

This is especially relevant when:

  • There are relatively few subjects
  • Covariance parameters are estimated
  • The design is unbalanced
  • There are missing observations
  • Different treatment groups have different numbers of observations

The choice of denominator degrees of freedom can therefore affect p-values and confidence intervals.

LS-Means

After fitting the model, analysts often want adjusted treatment means.

PROC MIXED provides these using the LSMEANS statement.

lsmeans TRT01P / diff cl;

This requests least-squares means for treatment, pairwise differences, and confidence limits.

For longitudinal trials, a more useful request is often treatment by visit:

lsmeans TRT01P*AVISIT /
    diff
    cl;

This produces adjusted means and comparisons for each treatment-by-visit combination.

Why LS-Means Are Important

The observed arithmetic mean and the model-based LS-mean are not necessarily the same.

The LS-mean represents a model-adjusted estimate of the mean outcome for a specified factor combination.

This is particularly useful when:

  • Baseline covariates are included
  • The dataset is unbalanced
  • There are missing observations
  • Interactions are present
  • Other fixed effects are included

Treatment Difference at a Specific Visit

Suppose the primary question is:

$$ \text{Drug A versus Placebo at Week 12} $$

The corresponding model-based comparison can be requested using:

lsmeans TRT01P*AVISIT /
    diff
    cl;

However, analysts often want only the relevant treatment comparison rather than every possible pair.

The PDIFF option and other LSMEANS options can be combined with appropriate SLICE or ESTIMATE/LSMESTIMATE statements depending on the desired contrast.

SLICE Effects

When an interaction is present, it is often useful to examine treatment effects within individual visits.

For example:

lsmeans TRT01P*AVISIT /
    slice=AVISIT
    diff
    cl;

This asks for treatment comparisons within levels of the visit factor.

Interpret interactions before reporting main effects. If treatment effects differ substantially across visits, a single overall treatment main effect may not answer the scientific question of interest.

Adding a Baseline Covariate

A common clinical-trial model adjusts post-baseline outcomes for baseline measurements.

Suppose the baseline value is BASE.

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model AVAL =
        BASE
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

    lsmeans TRT01P*AVISIT /
        diff
        cl;

run;

This is conceptually similar to a repeated-measures ANCOVA.

Why Baseline Adjustment Can Be Useful

Suppose two patients have different baseline values:

Patient Baseline Week 12
001 80 60
002 120 90

Both patients may show a similar proportional change even though their absolute values differ.

Including baseline as a covariate can improve precision and account for baseline heterogeneity.

Change From Baseline as the Dependent Variable

Another common analysis uses change from baseline:

$$ CHG_{ij}=Y_{ij}-Y_{i0} $$

The model then becomes:

model CHG =
    TRT01P
    AVISIT
    TRT01P*AVISIT
    / ddfm=kr;

Whether to analyze the raw post-baseline outcome with baseline adjustment or analyze change from baseline depends on the estimand, SAP, disease area, endpoint characteristics, and study design.

Do not switch between baseline-adjusted outcome and change-from-baseline models merely because one produces a more favorable result. The primary analysis should follow the prespecified statistical methodology.

The MMRM Framework

A particularly important application of PROC MIXED is the Mixed Model for Repeated Measures (MMRM).

A typical MMRM includes:

  • Treatment
  • Visit
  • Treatment-by-visit interaction
  • Baseline covariate where appropriate
  • Within-subject covariance structure

A representative SAS implementation is:

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model CHG =
        BASE
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

    lsmeans TRT01P*AVISIT /
        diff
        cl;

run;

Why MMRM Is Popular in Clinical Trials

MMRM has several useful properties for longitudinal clinical-trial data.

  • It models repeated observations directly.
  • It accounts for within-patient correlation.
  • It accommodates unequal numbers of observations per patient.
  • It can use information from patients with incomplete follow-up.
  • It provides model-based treatment comparisons at individual visits.
  • It does not require a single imputed value for every missing observation.

Missing Data

Missing observations are extremely common in longitudinal trials.

For example:

Patient Week 4 Week 8 Week 12 Week 24
001 Observed Observed Observed Observed
002 Observed Missing Observed Missing
003 Observed Observed Missing Missing

PROC MIXED does not require every subject to have observations at every visit.

This is one of its major advantages over traditional complete-case repeated- measures approaches.

MMRM and the Missing-at-Random Assumption

The validity of likelihood-based inference under incomplete longitudinal data depends on assumptions concerning the missingness mechanism.

A commonly invoked assumption is:

$$ MAR = \text{Missing At Random} $$

Under MAR, after conditioning on observed information included in the model, the probability of missingness does not depend on the unobserved value itself.

Important: PROC MIXED does not magically "solve" missing data. It provides likelihood-based estimation under assumptions about the missingness mechanism. Sensitivity analyses may be required when missing-not-at-random mechanisms are plausible.

Example of Early Treatment Discontinuation

Consider a patient who contributes:

$$ Week\;0,\;4,\;8,\;12 $$

but discontinues treatment after Week 12.

The patient can still contribute information to the model.

PROC MIXED does not require artificial values at Weeks 16 and 24 merely to retain the patient.

This is fundamentally different from approaches that require complete longitudinal records.

But Missingness Still Requires Clinical Investigation

A model-based analysis should not be interpreted without understanding why data are missing.

Important reasons include:

  • Adverse events
  • Lack of efficacy
  • Progressive disease
  • Withdrawal of consent
  • Loss to follow-up
  • Administrative reasons
  • COVID-era disruptions or other operational events

The mechanism behind missing data can be clinically important even when the primary analysis uses an MMRM.

Repeated Statement Versus Random Statement

One common source of confusion is the difference between:

random

and:

repeated

They are not interchangeable.

The RANDOM Statement

The RANDOM statement specifies random effects.

For example:

random intercept / subject=USUBJID;

This allows each patient to have their own random intercept.

Conceptually:

$$ Y_{ij} = X_{ij}\beta + b_i + \epsilon_{ij} $$

where \(b_i\) represents patient-specific random variation.

Random Slopes

A model can also allow individual patients to have different slopes over time.

random intercept WEEK /
    subject=USUBJID
    type=un;

This allows correlation between the patient-specific intercept and slope.

Such models can be useful when time is treated continuously and subject-specific growth trajectories are scientifically meaningful.

RANDOM Effects Versus REPEATED Covariance

A random-effects model and a repeated covariance model represent dependence in different ways.

Feature RANDOM REPEATED
Purpose Models random effects Models within-subject covariance
Typical use Random intercepts/slopes Longitudinal residual covariance
Subject specification SUBJECT= SUBJECT=
Common clinical MMRM approach Not necessarily required Often central
Practical point: A standard clinical-trial MMRM frequently uses a REPEATED statement with an appropriate covariance structure and does not require a RANDOM statement.

A Common MMRM Template

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model CHG =
        BASE
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

    lsmeans TRT01P*AVISIT /
        diff
        cl;

run;

This compact program contains most of the ingredients encountered in real-world clinical-trial longitudinal analyses.

Adding a Stratification Factor

Suppose randomization was stratified by geographic region.

The model could include the stratification factor:

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT REGION;

    model CHG =
        BASE
        REGION
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

    lsmeans TRT01P*AVISIT /
        diff
        cl;

run;

Whether a particular stratification factor belongs in the primary analysis should follow the SAP and statistical methodology.

Covariate Adjustment

Continuous baseline covariates can also be incorporated.

For example:

model CHG =
    BASE
    AGE
    TRT01P
    AVISIT
    TRT01P*AVISIT
    / ddfm=kr;

Categorical covariates should generally appear in the CLASS statement.

Interactions With Baseline Covariates

In some analyses, the effect of a baseline covariate may vary by treatment.

That could be represented by:

model CHG =
    BASE
    TRT01P
    AVISIT
    TRT01P*AVISIT
    BASE*TRT01P
    / ddfm=kr;

Such terms should not be added simply because they improve a model's fit.

They should have a statistical or scientific justification.

Reference Coding and CLASS Variables

SAS's CLASS-variable parameterization determines how model coefficients are represented.

For example:

class TRT01P(ref="Placebo")
      AVISIT(ref="Baseline");

This explicitly defines reference levels.

Reference-level choices can make parameter estimates easier to interpret.

Do not confuse reference coding with the scientific estimand. Changing the reference category changes the parameterization and interpretation of individual coefficients, but it does not inherently change the fitted model's underlying set of means.

Using ESTIMATE

The ESTIMATE statement can construct specific linear combinations of model parameters.

For example:

estimate "Treatment difference at Week 12"
    TRT01P*AVISIT 1 -1
    / cl;

The exact coefficients depend on the CLASS-variable parameterization.

For complex models, LS-means and LSMESTIMATE are often easier to maintain because the desired comparisons can be expressed in terms of factor levels.

Using LSMESTIMATE

An example pattern is:

lsmestimate TRT01P*AVISIT
    "Treatment difference at Week 12"
    0 0 1 -1
    / cl;

Again, the coefficient vector must match the ordering produced by the model.

Validation requirement: Never assume that an LSMESTIMATE coefficient vector is correct by visual inspection. Confirm the ordering of the LS-means and validate the resulting contrast against an independently calculated treatment difference.

Outputting Results to Datasets

ODS OUTPUT is particularly useful for production clinical programming.

ods output LSMeans=lsmeans
           Diffs=diffs
           Tests3=tests3
           CovParms=covparms;

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model CHG =
        BASE
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

    lsmeans TRT01P*AVISIT /
        diff
        cl;

run;

ods output close;

This is an important technique for integrating PROC MIXED into automated clinical-reporting pipelines.

Why ODS OUTPUT Matters

Instead of manually copying values from the SAS Results Viewer, production programs can capture model output directly into SAS datasets.

Those datasets can then be used to produce:

  • Tables
  • Listings
  • Figures
  • Statistical summaries
  • Automated validation reports

Key PROC MIXED Output Tables

Output What It Contains
CovParms Estimated covariance parameters
Tests3 Type III tests of fixed effects
LSMeans Estimated least-squares means
Diffs Differences among LS-means
SolutionF Fixed-effect parameter estimates
FitStatistics Model fit criteria

Reading the Covariance Parameters

Suppose the output contains covariance estimates such as:

Parameter Estimate
UN(1,1) 25.4
UN(2,1) 14.8
UN(2,2) 31.2

These values describe the estimated variability and covariance among repeated measurements.

They are not treatment effects.

Common mistake: Do not interpret covariance parameters as if they were treatment differences. They describe the dependence and variability structure used by the model.

Reading Type III Tests

The Type III tests provide hypothesis tests for fixed effects.

For example:

Effect F Value Pr > F
Treatment 4.82 0.031
Visit 18.42 <.001
Treatment × Visit 3.77 0.009

A statistically significant treatment-by-visit interaction indicates that the treatment effect is not constant across visits under the fitted model.

Do Not Stop at the Interaction P-Value

Suppose:

$$ P_{Treatment\times Visit}=0.009 $$

This indicates evidence that treatment differences vary by visit.

It does not directly answer:

  • What is the treatment difference at Week 12?
  • What is its confidence interval?
  • What is the adjusted p-value?

Those questions require appropriate contrasts or LS-means.

Confidence Intervals

A treatment comparison should generally be interpreted using its estimate and confidence interval rather than relying only on the p-value.

For example:

$$ \hat{\Delta} = -5.8 $$

with:

$$ 95\%\,CI=(-9.7,-1.9) $$

would indicate an estimated treatment difference of −5.8 units with the specified confidence interval.

The clinical interpretation depends on the endpoint and its direction.

Least-Squares Means Versus Raw Means

Suppose the raw observed means at Week 12 are:

Treatment Observed Mean
Drug A 61.2
Placebo 65.8

The model-adjusted LS-means might instead be:

Treatment LS-Mean
Drug A 60.7
Placebo 66.1

The difference is due to model adjustment.

Estimated Marginal Means Plot

Figure 2. Model-Based LS-Means With Confidence Intervals
Illustrative treatment profiles derived from a hypothetical longitudinal mixed model. Error bars represent 95% confidence intervals.

This display illustrates the type of figure commonly produced from PROC MIXED LS-means. The values are simulated and are not actual clinical-trial results.

Building a Complete Clinical-Trial Program

A production program will usually contain several components.

1
Create or identify the analysis dataset.
2
Define the analysis population.
3
Verify baseline and post-baseline records.
4
Define categorical analysis variables and reference levels.
5
Fit the prespecified PROC MIXED model.
6
Evaluate covariance-parameter estimation and convergence.
7
Generate LS-means and treatment contrasts.
8
Capture output using ODS OUTPUT.
9
Create the final table or figure.
10
Independently validate the results.

Checking Convergence

A successful SAS program execution does not necessarily mean that the fitted model is scientifically or statistically satisfactory.

The programmer should inspect:

  • Convergence status
  • Covariance parameter estimates
  • Warnings in the SAS log
  • Boundary estimates
  • Positive-definiteness issues
  • Singularities
  • Unexpected standard errors
Never ignore SAS log warnings. A model that technically produces output can still require investigation if the covariance structure is poorly estimated or the optimization encounters numerical difficulties.

When UN Does Not Converge

An unstructured covariance model may fail when:

  • The number of visits is large relative to sample size.
  • Some visits contain very few observations.
  • There is substantial missingness.
  • Correlation parameters are poorly identified.
  • The data contain little information about certain covariance components.

Possible alternatives include more parsimonious structures such as:

type=cs
type=ar(1)
type=toep

However, the alternative should be selected according to the prespecified strategy or justified statistical methodology.

Unequal Numbers of Visits

A major advantage of PROC MIXED is that patients do not need to have identical numbers of observations.

For example:

Patient Number of Measurements
001 6
002 6
003 4
004 3
005 6

PROC MIXED can use the available observations rather than automatically discarding every patient who lacks a complete record.

Unequal Visit Timing

There is an important distinction between categorical visit and actual elapsed time.

Suppose assessments occur at:

$$ Day\;28,\;Day\;56,\;Day\;91,\;Day\;120 $$

If AVISIT is treated categorically, the exact spacing between these visits does not directly determine the mean structure.

If a continuous time variable is used, the spacing becomes part of the model.

Important: Do not assume that using a continuous time variable is equivalent to using categorical visit. They represent different scientific assumptions.

Visit as a CLASS Variable

For a standard scheduled-visit MMRM:

class AVISIT;

model CHG =
    BASE
    TRT01P
    AVISIT
    TRT01P*AVISIT
    / ddfm=kr;

The model makes no assumption that the treatment effect changes linearly between visits.

This flexibility is one reason categorical visit is common in clinical-trial MMRM analyses.

Continuous Time Model

A different model might use:

model CHG =
    BASE
    TRT01P
    WEEK
    TRT01P*WEEK
    / ddfm=kr;

This assumes a specified functional relationship between outcome and time.

If the true trajectory is strongly nonlinear, a simple linear time term may be inappropriate.

Polynomial Time Effects

A more flexible continuous-time model could include quadratic time:

model CHG =
    BASE
    TRT01P
    WEEK
    WEEK*WEEK
    TRT01P*WEEK
    TRT01P*WEEK*WEEK
    / ddfm=kr;

This allows curvature.

However, increasingly complex mean structures should be supported by the study's scientific objectives rather than added indiscriminately.

Post-Baseline Population

A common MMRM uses post-baseline records as the repeated observations and includes baseline separately as a covariate.

For example:

data mmrm;
    set analysis;
    where ANL01FL="Y"
          and AVISITN > 0;
run;

The exact filtering criteria depend on the analysis dataset and SAP.

Be explicit about baseline. If baseline is used as a covariate, it does not necessarily need to be included as one of the repeated response measurements. The model structure should match the prespecified analysis.

Example Analysis Dataset

USUBJID TRT01P AVISITN AVISIT      BASE  CHG
001     Drug A     4   Week 4      72   -7
001     Drug A     8   Week 8      72  -11
001     Drug A    12   Week 12     72  -14
001     Drug A    24   Week 24     72  -18
002     Placebo    4   Week 4      70   -1
002     Placebo    8   Week 8      70    1
002     Placebo   12   Week 12     70    0
002     Placebo   24   Week 24     70    2

This structure is suitable for a repeated-measures analysis because each patient contributes multiple post-baseline rows.

Sorting the Data

It is good programming practice to sort longitudinal analysis data by subject and analysis visit.

proc sort data=analysis out=analysis_sorted;
    by USUBJID AVISITN;
run;

Sorting is especially useful for inspection and validation even when the procedure itself does not require a particular physical ordering in every situation.

Duplicate Records

Repeated-measures models require careful attention to duplicate observations.

For example, the following may indicate a problem:

001   Week 12   -14
001   Week 12   -15

The analyst should determine whether these represent:

  • Duplicate records
  • Unscheduled assessments
  • Multiple measurements requiring a derivation rule
  • Data-entry errors

The model should not simply be allowed to treat an accidental duplicate as another independent repeated observation.

Unscheduled Assessments

Clinical trials often contain unscheduled visits.

The analysis specification should define whether these observations are:

  • Excluded
  • Mapped to a nominal visit
  • Used according to actual timing
  • Used only for sensitivity analyses

This is an analysis-data derivation issue as much as it is a modeling issue.

Covariance Structure by Treatment

In some settings, the analyst may want different covariance structures by treatment group.

For example:

repeated AVISIT /
    subject=USUBJID
    type=un
    group=TRT01P;

The GROUP= option permits covariance parameters to differ across groups.

This can be useful in some analyses but also increases model complexity.

Use GROUP= deliberately. Allowing separate covariance parameters by treatment can consume substantially more information and may create convergence problems, particularly in small samples.

Randomization Stratification Versus Covariance Grouping

These concepts should not be confused.

Concept Purpose
Stratification factor Fixed-effect adjustment for design or prognostic factor
GROUP= in REPEATED Allows covariance parameters to differ across groups

Model Selection Workflow

1
Define the mean structure from the SAP.
2
Identify the repeated measurement dimension.
3
Specify candidate covariance structures.
4
Fit candidate models using the appropriate estimation method.
5
Check convergence and covariance estimates.
6
Compare information criteria when appropriate.
7
Apply the prespecified covariance-selection rule.
8
Freeze the selected model before production reporting.

Model Fit Statistics

Suppose three candidate models produce:

Structure AIC AICC BIC
CS 1542.3 1543.0 1564.8
AR(1) 1538.6 1539.2 1561.1
UN 1534.1 1537.0 1580.2

There is no single criterion that should automatically determine the final model.

The analysis plan may specify, for example, a particular hierarchy of candidate structures and a selection criterion.

Why AICC Can Be Useful

AIC can favor overly complex models in smaller samples.

AICC applies a finite-sample correction.

This can be particularly useful when the number of covariance parameters is not negligible relative to the amount of information available.

Model Diagnostics

PROC MIXED analyses should also consider residual diagnostics.

Useful questions include:

  • Are residuals approximately symmetric?
  • Are there extreme outliers?
  • Is variance changing substantially over time?
  • Does the covariance structure appear plausible?
  • Are there influential observations?

Formal diagnostic procedures should be proportionate to the role of the model in the study.

Residual Diagnostics

ODS GRAPHICS can be enabled for additional diagnostics.

ods graphics on;

proc mixed data=analysis method=reml;
    class USUBJID TRT01P AVISIT;

    model CHG =
        BASE
        TRT01P
        AVISIT
        TRT01P*AVISIT
        / ddfm=kr;

    repeated AVISIT /
        subject=USUBJID
        type=un;

run;

ods graphics off;

Influential Patients

Because longitudinal models use multiple observations from each patient, individual patients can sometimes have substantial influence on parameter estimates.

A patient with:

  • Very unusual baseline values
  • Extreme longitudinal changes
  • Many observations
  • Unusual covariance behavior

may deserve additional investigation.

Do not automatically remove influential patients. Clinical-trial analyses should follow predefined data-review and analysis rules rather than removing observations because they make the treatment effect less favorable.

What Does a Treatment-by-Visit Interaction Mean?

Suppose the estimated treatment differences are:

Visit Drug A − Placebo
Week 4 −1.2
Week 8 −3.8
Week 12 −6.4
Week 24 −8.1

The treatment effect appears to become progressively larger.

A significant interaction would be consistent with the hypothesis that treatment differences vary over time.

What If the Interaction Is Not Significant?

A nonsignificant treatment-by-visit interaction does not necessarily mean that there is no treatment benefit.

It means there is insufficient statistical evidence, under the specified model, that treatment differences vary across visits.

The interpretation of the treatment main effect then depends on the exact model, estimand, and analysis objective.

Do not use a nonsignificant interaction as an automatic reason to delete the interaction from the primary model. Model specification should follow the prespecified statistical analysis.

Estimated Treatment Difference at Week 24

Suppose the model produces:

$$ \hat{\Delta}_{Week24} = -8.1 $$

with:

$$ 95\%\,CI=(-12.4,-3.8) $$

The model therefore estimates an 8.1-unit lower mean outcome for Drug A relative to Placebo at Week 24, subject to the endpoint's interpretation and the specified direction of benefit.

Multiple Comparisons

When treatment is compared at many visits, multiple statistical comparisons may arise.

PROC MIXED supports multiplicity adjustments for appropriate LS-means comparisons.

For example:

lsmeans TRT01P*AVISIT /
    diff
    adjust=tukey
    cl;

Other adjustments may be appropriate depending on the comparison family and the statistical-analysis plan.

Multiplicity is an estimand and reporting issue, not merely a SAS syntax issue. The appropriate adjustment depends on which hypotheses are considered part of the same family and what inferential claim the study intends to make.

Producing a Treatment Profile From LS-Means

The model can produce adjusted means that are then plotted over time.

Conceptually:

$$ \text{PROC MIXED} \rightarrow \text{LS-means} \rightarrow \text{confidence intervals} \rightarrow \text{longitudinal figure} $$

This is often more appropriate for a clinical-trial report than simply plotting raw arithmetic means.

Example SAS Output Workflow

ods output
    LSMeans=work.lsmeans
    Diffs=work.diffs
    CovParms=work.covparms
    Tests3=work.tests3
    SolutionF=work.solutionf
    FitStatistics=work.fitstats;

proc mixed data=analysis method=reml;

    class
        USUBJID
        TRT01P
        AVISIT;

    model
        CHG =
            BASE
            TRT01P
            AVISIT
            TRT01P*AVISIT
            / ddfm=kr
              solution;

    repeated
        AVISIT /
        subject=USUBJID
        type=un;

    lsmeans
        TRT01P*AVISIT /
        diff
        cl;

run;

ods output close;

Building a Reusable Macro

Clinical programming teams often encapsulate repeated model specifications in macros.

%macro run_mmrm(
    data=,
    out_lsmeans=,
    out_diffs=,
    out_cov=,
    covtype=UN
);

    ods output
        LSMeans=&out_lsmeans
        Diffs=&out_diffs
        CovParms=&out_cov;

    proc mixed data=&data method=reml;

        class
            USUBJID
            TRT01P
            AVISIT;

        model
            CHG =
                BASE
                TRT01P
                AVISIT
                TRT01P*AVISIT
                / ddfm=kr;

        repeated
            AVISIT /
            subject=USUBJID
            type=&covtype;

        lsmeans
            TRT01P*AVISIT /
            diff
            cl;

    run;

    ods output close;

%mend;

%run_mmrm(
    data=analysis,
    out_lsmeans=lsmeans_un,
    out_diffs=diffs_un,
    out_cov=cov_un,
    covtype=UN
);

Reusable macros can reduce duplicated code across endpoints and studies.

Production-programming caution: A reusable macro should make assumptions explicit. Do not hide critical analysis decisions such as baseline definition, population flags, covariance selection, or multiplicity adjustment inside a macro without documenting them.

MMRM Validation

Validation should occur at several levels.

Validation Layer Example
Data Verify analysis population and records
Derivation Verify baseline and change-from-baseline calculations
Model Verify fixed effects and covariance structure
Output Verify LS-means and treatment differences
Presentation Verify rounding, labels, confidence intervals, and footnotes

Independent Validation of LS-Means

A strong validation strategy should not simply rerun identical SAS code.

For example, the production analysis could be validated against:

  • An independently programmed SAS implementation
  • R or another statistical package
  • Manual calculations for selected simple contrasts
  • Known test datasets
  • Historical validated outputs

The validation method should be appropriate for the complexity of the model.

Manual Validation of a Simple Difference

Suppose two estimated means at Week 12 are:

$$ \hat{\mu}_A=61.2 $$

and:

$$ \hat{\mu}_P=66.4 $$

The estimated difference is:

$$ 61.2-66.4=-5.2 $$

The corresponding PROC MIXED contrast should agree with this value, subject to the exact LS-means and contrast definition.

Common PROC MIXED Mistakes

  1. Ignoring within-subject correlation. Repeated observations from the same patient are not generally independent.
  2. Using the wrong SUBJECT= variable. The subject variable should represent the independent clustering unit.
  3. Automatically choosing TYPE=UN. UN is flexible but can become unstable as the number of visits increases.
  4. Automatically choosing TYPE=CS. CS may be too restrictive for longitudinal data whose correlation decreases with time.
  5. Confusing RANDOM and REPEATED. They represent different aspects of mixed-model specification.
  6. Ignoring convergence warnings. Successful output does not guarantee an adequate model fit.
  7. Interpreting covariance parameters as treatment effects. Covariance parameters describe variability and correlation.
  8. Reporting raw means when the analysis requires LS-means. The inferential result should correspond to the prespecified model.
  9. Ignoring multiplicity. Multiple treatment comparisons can require adjustment.
  10. Changing the model after seeing the results. Primary-model specifications should be prespecified.
  11. Assuming PROC MIXED solves missing data automatically. Inference depends on assumptions about the missingness mechanism.
  12. Failing to validate the treatment contrast. The final estimate should be independently traceable.

PROC MIXED Versus PROC GLIMMIX

PROC MIXED is primarily intended for linear mixed models with approximately normally distributed continuous outcomes.

For non-normal outcomes requiring generalized linear mixed models, PROC GLIMMIX may be more appropriate.

Procedure Typical Use
PROC MIXED Continuous approximately normal longitudinal outcomes
PROC GLIMMIX Generalized mixed models for non-normal outcomes
PROC GENMOD Generalized linear models without the same mixed-model structure

The endpoint distribution and estimand should determine the modeling approach.

PROC MIXED Versus PROC GLM

PROC GLM can analyze many fixed-effects designs, but it is not a direct replacement for a mixed model when within-subject covariance must be modeled.

The distinction becomes particularly important with:

  • Unequal numbers of observations
  • Missing longitudinal measurements
  • Complex covariance structures
  • Random effects

PROC MIXED Versus Repeated-Measures ANOVA

Traditional repeated-measures ANOVA often relies on restrictive covariance assumptions such as sphericity.

PROC MIXED allows the analyst to specify alternative covariance structures directly.

This makes mixed models substantially more flexible for many modern longitudinal clinical-trial designs.

Clinical-Trial Interpretation

Suppose the analysis estimates the treatment difference at Week 12 as:

$$ -4.8 \quad (95\%\,CI:\;-8.2,\;-1.4) $$

The appropriate interpretation is that the model estimates a 4.8-unit lower mean outcome in the treatment group relative to control at Week 12, with the specified confidence interval.

The clinical importance depends on the endpoint's measurement scale.

For a symptom score, a 4.8-unit difference might be clinically important. For a laboratory value, the same numerical difference might be trivial.

Statistical Significance Is Not Clinical Significance

Suppose a very large trial estimates:

$$ \hat{\Delta}=-0.7 \qquad P<0.001 $$

The result may be statistically significant while having limited clinical importance.

Clinical interpretation should therefore consider:

  • Magnitude of the treatment effect
  • Confidence interval
  • Known clinically meaningful thresholds
  • Safety
  • Other efficacy endpoints
  • Overall benefit-risk profile

Responder Analysis Is Different

PROC MIXED is generally designed for continuous longitudinal outcomes.

If the endpoint is a binary responder status, a different modeling approach may be required.

For example:

  • Responder/non-responder
  • Event/no event
  • Count outcomes

may require generalized models rather than a standard linear mixed model.

Repeated Measures With Binary Outcomes

For a binary longitudinal endpoint, a generalized mixed model may be more appropriate.

Conceptually:

$$ logit\{P(Y_{ij}=1)\} = X_{ij}\beta + Z_{ij}b_i $$

This is outside the standard PROC MIXED framework.

Choose the procedure based on the endpoint distribution. Do not use PROC MIXED simply because the data are repeated. The response distribution and scientific estimand determine the appropriate statistical model.

Repeated Measures and Baseline Adjustment

One common clinical-trial specification is:

$$ Y_{ij} = \beta_0 + \beta_1 BASE_i + \beta_2 TRT_i + \beta_3 VISIT_j + \beta_4 TRT_iVISIT_j + \epsilon_{ij} $$

The baseline value is a patient-level covariate, while treatment and visit describe the longitudinal mean structure.

Why Baseline Should Be Examined Carefully

Baseline should not simply be inserted into the model because it is available.

The analyst should consider:

  • How baseline is defined
  • Whether baseline is measured before treatment
  • Whether the baseline value is appropriate for the endpoint
  • Whether baseline is part of the estimand
  • Whether the SAP specifies adjustment

Model Specification Checklist

1
Confirm the analysis population.
2
Confirm the baseline definition.
3
Confirm whether the response is raw outcome or change from baseline.
4
Confirm treatment coding and reference group.
5
Confirm the visit definition.
6
Confirm treatment-by-visit interaction.
7
Confirm covariance structure.
8
Confirm denominator degrees-of-freedom method.
9
Confirm multiplicity strategy.
10
Confirm final contrasts and reporting rules.

MMRM Programming Checklist

Item Question
Population Are all included patients correctly flagged?
Baseline Is the baseline value correct?
Outcome Is the analysis variable derived correctly?
Visit Are nominal visits correctly assigned?
Treatment Is treatment assignment correct?
Covariance Is the prespecified covariance structure used?
DDFM Is the correct denominator degrees-of-freedom method used?
LS-means Are the requested comparisons correct?
Multiplicity Are adjustments applied according to the SAP?
Output Are values correctly captured and reported?

Example of a Complete Production-Style Program

/*=========================================================
  MMRM ANALYSIS
  Endpoint: Change from Baseline
=========================================================*/

proc sort
    data=adam.adqs
    out=work.mmrm;
    by USUBJID AVISITN;
run;

ods output
    LSMeans      = work.mmrm_lsmeans
    Diffs        = work.mmrm_diffs
    CovParms     = work.mmrm_covparms
    Tests3       = work.mmrm_tests3
    SolutionF    = work.mmrm_solutionf
    FitStatistics= work.mmrm_fit;

proc mixed
    data=work.mmrm
    method=reml;

    class
        USUBJID
        TRT01P
        AVISIT;

    model
        CHG =
            BASE
            TRT01P
            AVISIT
            TRT01P*AVISIT
            / ddfm=kr
              solution;

    repeated
        AVISIT /
        subject=USUBJID
        type=un;

    lsmeans
        TRT01P*AVISIT /
        diff
        cl;

run;

ods output close;

This is intentionally written in a form resembling the type of program that might be adapted for a production clinical-trial analysis.

Production Programming Considerations

In a regulated clinical environment, the final program should also make clear:

  • Source datasets
  • Analysis population flags
  • Endpoint derivations
  • Baseline rules
  • Visit windows
  • Covariance-selection rules
  • Model version
  • Output datasets
  • Rounding rules
  • Validation procedures

The goal is reproducibility.

Model Version Control

A small change in the model can materially change the reported results.

For example, changing:

type=un

to:

type=ar(1)

changes the covariance assumptions.

Changing:

ddfm=kr

to another degrees-of-freedom method can also change inferential results.

These changes should therefore be version-controlled and documented.

What Should Be Reported?

A clinical-trial table based on PROC MIXED might include:

  • Number of patients
  • Adjusted mean
  • Standard error
  • 95% confidence interval
  • Treatment difference
  • 95% confidence interval for treatment difference
  • P-value where appropriate

The exact reporting format depends on the SAP and table shell.

Example Clinical-Trial Table

Visit Drug A LS-Mean Placebo LS-Mean Difference 95% CI
Week 4 −2.1 −0.8 −1.3 (−3.7, 1.1)
Week 8 −5.6 −1.7 −3.9 (−6.5, −1.3)
Week 12 −8.4 −2.0 −6.4 (−9.4, −3.4)
Week 24 −10.1 −2.7 −7.4 (−11.0, −3.8)

These values are illustrative.

Reading the Example Table

The treatment difference becomes increasingly negative over time.

If lower values indicate improvement, this would suggest increasing benefit over time.

The confidence intervals provide information about the precision of each estimate.

Longitudinal Plot and Table Together

A useful clinical-trial reporting strategy is to combine:

A
Summary table: reports model-based numerical estimates.
B
LS-mean plot: displays the treatment profiles visually.
C
Patient-level plot: shows individual longitudinal heterogeneity where appropriate.

The table provides precision.

The figure provides pattern recognition.

The patient-level display provides context about heterogeneity.

Common Questions About PROC MIXED

Does PROC MIXED require complete data?

No. Patients can contribute different numbers of observations, although the validity of inference with missing data depends on the assumptions of the analysis.

Does PROC MIXED automatically impute missing values?

No. PROC MIXED uses likelihood-based estimation with the observed data under the specified model; it does not create a conventional single imputed value for each missing observation.

Should every longitudinal model use TYPE=UN?

No. UN is flexible but may be inefficient or unstable with many visits or limited sample size.

Should visit always be categorical?

No. Categorical visit is common when estimating visit-specific treatment effects, but continuous-time models may be appropriate for other scientific questions.

Is PROC MIXED only for randomized clinical trials?

No. It can be used for many longitudinal and clustered continuous outcomes, including observational studies, laboratory studies, repeated-measure experiments, and clinical trials.

Does a significant treatment effect prove clinical benefit?

No. Statistical significance must be interpreted together with effect size, precision, endpoint meaning, multiplicity, safety, and the prespecified estimand.

When PROC MIXED Is a Good Choice

PROC MIXED is particularly useful when:

  • The outcome is continuous.
  • Measurements are repeated within subjects.
  • Within-subject correlation is important.
  • The data are unbalanced.
  • Patients have incomplete longitudinal follow-up.
  • A covariance structure can reasonably represent the repeated observations.
  • Model-based adjusted means are desired.

When to Consider Another Approach

Another modeling framework may be more appropriate when:

  • The outcome is binary.
  • The outcome is a count.
  • The outcome is strongly non-normal.
  • The endpoint is time-to-event.
  • The scientific question is explicitly subject-specific.
  • The missing-data mechanism requires a specialized sensitivity analysis.

PROC MIXED and Regulatory Reporting

For regulated clinical-trial analyses, the model should be traceable to the statistical-analysis plan.

The programmer should be able to answer:

  • Why was this endpoint analyzed?
  • Why was this baseline definition used?
  • Why was this covariance structure selected?
  • Why was this degrees-of-freedom method used?
  • Why were these treatment comparisons requested?
  • How was multiplicity handled?
  • How were missing data handled?

The SAS program is therefore an implementation of the statistical methodology, not a substitute for the methodology itself.

MMRM and the Estimand

Modern clinical-trial analysis should distinguish the statistical model from the estimand.

The model describes how observed outcomes are analyzed.

The estimand describes the treatment effect being targeted.

Questions such as treatment policy, hypothetical, while-on-treatment, or other strategies can affect how intercurrent events and post-discontinuation measurements are handled.

Important: PROC MIXED syntax cannot define the clinical estimand by itself. The data handling rules, endpoint definition, intercurrent-event strategy, and model must collectively implement the prespecified estimand.

Post-Treatment Measurements

Whether post-treatment observations belong in the primary MMRM depends on the estimand and SAP.

For example, a treatment-policy strategy may retain certain observations after treatment discontinuation, whereas a hypothetical strategy may require a different framework.

Therefore, "include all available observations" is not universally correct.

Sensitivity Analyses

Sensitivity analyses can evaluate how conclusions change under alternative assumptions.

Examples may include:

  • Alternative covariance structures
  • Alternative missing-data assumptions
  • Pattern-mixture models
  • Reference-based imputation
  • Alternative analysis populations
  • Alternative handling of intercurrent events

These analyses should be prespecified or appropriately documented.

A Practical MMRM Decision Tree

1
Is the endpoint approximately continuous and suitable for a linear model?
If yes: consider PROC MIXED.
2
Are observations repeated within subjects?
If yes: specify the subject and covariance structure.
3
Are visit-specific treatment effects required?
If yes: include treatment-by-visit.
4
Is baseline adjustment prespecified?
If yes: include the appropriate baseline covariate.
5
Are there missing observations?
If yes: understand the missingness assumptions.
6
Are multiple covariance structures plausible?
If yes: follow the prespecified covariance-selection strategy.
7
Are specific treatment comparisons required?
If yes: define LS-means or appropriate contrasts.

Example End-to-End Analysis

Suppose a randomized clinical trial compares Drug A with Placebo. The primary continuous endpoint is measured at Weeks 4, 8, 12, and 24. The SAP specifies:

  • Change from baseline as the response
  • Baseline as a covariate
  • Treatment as a fixed effect
  • Visit as a categorical fixed effect
  • Treatment-by-visit interaction
  • Unstructured covariance
  • REML estimation
  • Kenward–Roger degrees of freedom
  • LS-mean treatment comparisons at each visit

The corresponding program is:

proc mixed
    data=analysis
    method=reml;

    class
        USUBJID
        TRT01P
        AVISIT;

    model
        CHG =
            BASE
            TRT01P
            AVISIT
            TRT01P*AVISIT
            / ddfm=kr;

    repeated
        AVISIT /
        subject=USUBJID
        type=un;

    lsmeans
        TRT01P*AVISIT /
        diff
        cl;

run;

How to Explain the Model to a Non-Programmer

A useful explanation is:

Plain-language interpretation: The model compares the treatment groups over time while accounting for the fact that repeated measurements from the same patient are correlated. It adjusts for baseline, estimates treatment-specific mean outcomes at each visit, and uses the specified covariance structure to obtain appropriate standard errors and confidence intervals.

The Three Most Important PROC MIXED Statements

For a standard longitudinal clinical-trial analysis, remember:

class ...;

defines categorical variables.

model ...;

defines the fixed-effects mean structure.

repeated ... / subject=... type=...;

defines the repeated-measures covariance structure.

Everything else builds on these concepts.

A Compact MMRM Cheat Sheet

Goal SAS Syntax
Fit mixed model proc mixed;
Use REML method=reml
Define categorical variables class
Specify fixed effects model
Specify repeated covariance repeated
Identify subject subject=USUBJID
Unstructured covariance type=un
Compound symmetry type=cs
AR(1) type=ar(1)
Kenward–Roger ddfm=kr
LS-means lsmeans
Pairwise differences diff
Confidence intervals cl
Capture output ods output

The Most Important Concept

The most important thing to understand about PROC MIXED for repeated measures is that the covariance structure is part of the model.

The fixed effects answer:

$$ \text{What are the expected mean outcomes?} $$

The covariance structure answers:

$$ \text{How are repeated observations within a patient related?} $$

Both components are necessary for a properly specified longitudinal mixed model.

Final Clinical-Trial Workflow

1
Define the estimand and endpoint.
2
Define the analysis population and baseline.
3
Prepare the longitudinal analysis dataset.
4
Specify treatment, visit, and treatment-by-visit effects.
5
Specify baseline adjustment if required.
6
Select the prespecified covariance structure.
7
Fit PROC MIXED using the appropriate estimation and DDFM method.
8
Review convergence and covariance estimates.
9
Generate LS-means, contrasts, confidence intervals, and p-values as specified.
10
Validate the results independently before reporting.

Bottom Line

PROC MIXED is one of the core SAS procedures for longitudinal clinical-trial analysis. It allows statistical programmers to model continuous repeated outcomes while accounting for within-patient correlation. A typical MMRM contains treatment, visit, treatment-by-visit interaction, and often baseline adjustment in the fixed-effects portion of the model, with a covariance structure specified in the REPEATED statement. The choice of covariance structure, degrees-of-freedom method, missing-data assumptions, contrasts, and multiplicity strategy should be driven by the statistical-analysis plan rather than selected solely from the observed results. The essential SAS pattern is:
proc mixed data=analysis method=reml;

    class
        USUBJID
        TRT01P
        AVISIT;

    model
        CHG =
            BASE
            TRT01P
            AVISIT
            TRT01P*AVISIT
            / ddfm=kr;

    repeated
        AVISIT /
        subject=USUBJID
        type=un;

    lsmeans
        TRT01P*AVISIT /
        diff
        cl;

run;

Once this structure is understood, many more advanced longitudinal models become much easier to interpret.

References

Littell, R.C., Milliken, G.A., Stroup, W.W., Wolfinger, R.D., & Schabenberger, O. SAS for Mixed Models. SAS Institute.

Westfall, P.H., Tobias, R.D., Rom, D., Wolfinger, R.D., & Hochberg, Y. Multiple Comparisons and Multiple Tests Using SAS. SAS Institute.

Kenward, M.G. & Roger, J.H. (1997). Small sample inference for fixed effects from restricted maximum likelihood. Biometrics, 53, 983–997.

SAS Institute Inc. SAS/STAT User's Guide: The MIXED Procedure. SAS Institute.

Fitzmaurice, G.M., Laird, N.M., & Ware, J.H. Applied Longitudinal Analysis. Wiley.

Mallinckrodt, C.H., Clark, W.S., & David, S.R. (2001). Accounting for dropout bias using mixed-effects models. Journal of Biopharmaceutical Statistics.