Hello,
I need some help obtaining the random slope estimates per individual, so that I can use those parameters per individual as an outcome in another part of the analysis.
Below is the code that I am currently using:
ods output solutionf=slopes;
proc mixed data=trial;
class idno time;
model GLOBALCOG = time WMFA WMH ICV brainvol AGE RACE GENDER/s chisq OUTPM=WORK.PM RESIDUAL;
random intercept time;
repeated time/type=un subject=idno r rcorr;
run;
The part "solutionf=slopes" provide one parameter of the random slope but not per individual.
Thanks!
If this random slope is one slope for one subject. Try this:
data trial; call streaminit(123); do idno=1 to 10; do time=1 to 4; globalcog=rand('normal'); brain=rand('normal'); output; end; end; run; ods output SolutionR= SolutionR; proc mixed data=trial; class idno time ; model GLOBALCOG = time brain/s chisq RESIDUAL; /*random intercept /subject=idno solution ;*/ random brain/subject=idno solution ; /*repeated time/type=un subject=idno r rcorr;*/ run;
Is this what you are looking for?
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_mixed_examples05.htm
Yes! Thanks for sharing. However, what it's still not clear is how to extract the random slope parameters per individual as a column that you could add to the dataset to use for analysis. I'd greatly appreciate suggestions!
I think your code should look like this:
data trial; call streaminit(123); do idno=1 to 10; do time=1 to 4; globalcog=rand('normal'); brain=rand('normal'); output; end; end; run; ods output SolutionR= SolutionR; proc mixed data=trial; class idno time; model GLOBALCOG = time brain/s chisq RESIDUAL; random intercept /subject=idno solution ; repeated time/type=un subject=idno r rcorr; run;
If this random slope is one slope for one subject. Try this:
data trial; call streaminit(123); do idno=1 to 10; do time=1 to 4; globalcog=rand('normal'); brain=rand('normal'); output; end; end; run; ods output SolutionR= SolutionR; proc mixed data=trial; class idno time ; model GLOBALCOG = time brain/s chisq RESIDUAL; /*random intercept /subject=idno solution ;*/ random brain/subject=idno solution ; /*repeated time/type=un subject=idno r rcorr;*/ run;
First, your PROC MIXED code does not seem to be appropriate. It looks to me that you wanted to fit a random coefficients model? If so, TIME should not be a CLASS variable, and you should have the SUBJECT= option in the RANDOM statement. Then with this modified RANDOM statement, your REPEATED statement with TYPE=UN structure is likely over-fitting your data and might need to be removed.
proc mixed data=trial;
class idno ;
model GLOBALCOG = time WMFA WMH ICV brainvol AGE RACE GENDER/s chisq OUTPM=WORK.PM RESIDUAL;
random intercept time / subject=idno;
run;
Then you might use approaches illustrated in the following usage note to obtain subject-specific intercept and slope estimates.
Hope this helps,
Jill
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.