BookmarkSubscribeRSS Feed
ehowie
Calcite | Level 5

Does anyone know how to create linear combinations using proc mixed or plm? In Stata, the syntax is lincom.

For example, if you were to model the change in gallons of ice cream consumed for 6 months in a particular population, with data collected at each month. Contrast and lsmestimates can be used to compare the predicted means for each month (ie ice cream at 1 vs 2 months), but how can I test if the change from 1 to 2 months is different from the change from 2 to 3 months. The basic model would be:

proc mixed data=heatwave;

class id month;

model icecream=month;

random int /subject=id;

run;

2 REPLIES 2
SteveDenham
Jade | Level 19

LSMESTIMATES are additve, so for your example, in GLIMMIX, I would have something like:

proc glimmix data=heatwave;

class id month;

model icecream=month;

random month/residual type=ar(1) subject=id;

random int / subject=id;

lsmestimate month 'Month 2 minus Month 1' -1 1 0 0 0 0,

                             'Month 3 minus Month 2' 0 -1 1 0 0 0,

                             'Difference' 1 -2 1 0 0 0;

run;

In this case, I just subtracted the first line from the second.  This could be extended as needed.

Steve Denham

Message was edited by: Steve Denham

ehowie
Calcite | Level 5

Aha! I knew it had to be something simple. Thanks!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 2212 views
  • 0 likes
  • 2 in conversation