Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GiaLee
Obsidian | Level 7

Hi,

I have a question about plotting a figure for a mixed model. Time is a categorical variable, the outcome is a score, and the covariate is the site.

 

Here is my code:

PROC MIXED DATA = test          METHOD = REML COVTEST ;
CLASS id    site      time_dichotomous_number(ref="1");
MODEL Score =time_dichotomous_number     site   time_dichotomous_number*site/ SOLUTION OUTPRED=PREDDATA;
RANDOM INTERCEPT / SUBJECT = record_id;
repeatedtime_dichotomous_number / type=ar(1) sub=id;
store out=MixedModel;
RUN;

proc plm restore=MixedModel;
effectplot interaction (x=site   sliceby=time_dichotomous_number) / clm connect;
effectplot interaction (x=time_dichotomous_number sliceby=site) / clm connect;
run;

Screen Shot 2024-02-22 at 11.23.14.png

Regardless of how I label the categorical time variable, whether it's named 1-7, using letters (a, b, c, d...), or with a space before the letter, the figure consistently put time 1 at the end (Time 1 is the reference group when running the mixed model). Does anyone know how to position time 1 before time 2? Thanks!

 

Additionally, on the y-axis, it is labeled as "linear predictor." Is this the mean predicted value generated from the mixed model? 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jiltao
SAS Super FREQ

One way to get what you wanted is to run PROC MIXED twice. Once with the (ref="1") option in the CLASS statement so you get what you want for the parameter estimates, and no STORE statement is needed. Then you can run PROC MIXED the second time, with no (ref="1") option in the CLASS statement. Use the STORE statement this time. Then your PROC PLM output should display the time in the order as you wanted. To speed up the second PROC MIXED, you might add NOTEST option in the MODEL statement, also add NOINFO NOITPRINT NOCLPRINT options in the PROC MIXED statement.

Alternatively, you might define a format for your variable  time_dichotomous_number, such that the format for "1" comes first alphabetically, and assign this format to the variable  time_dichotomous_number.

Yes, the values being plotted are the predicated values from your PROC MIXED model.

 

Hope this helps,

Jill

View solution in original post

2 REPLIES 2
jiltao
SAS Super FREQ

One way to get what you wanted is to run PROC MIXED twice. Once with the (ref="1") option in the CLASS statement so you get what you want for the parameter estimates, and no STORE statement is needed. Then you can run PROC MIXED the second time, with no (ref="1") option in the CLASS statement. Use the STORE statement this time. Then your PROC PLM output should display the time in the order as you wanted. To speed up the second PROC MIXED, you might add NOTEST option in the MODEL statement, also add NOINFO NOITPRINT NOCLPRINT options in the PROC MIXED statement.

Alternatively, you might define a format for your variable  time_dichotomous_number, such that the format for "1" comes first alphabetically, and assign this format to the variable  time_dichotomous_number.

Yes, the values being plotted are the predicated values from your PROC MIXED model.

 

Hope this helps,

Jill

GiaLee
Obsidian | Level 7
Thank you!! The first method works, it's amazing!
Regarding the second method, could you provide more clarification? I tried to label the time categories as "1", "a", "b", "c", but "1" still appears after "c".

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 668 views
  • 1 like
  • 2 in conversation