Hello, I am trying to figure out how to generate plots from mixed-effects models from SAS. I am interested to see whether group show statistical differences on outcomes (measured at t0 and t2) at different time points (t0 and t2). Specifically, I am looking for a plot similar to ggeffects in R with predicted means, values between these two groups.
Please see the SAS codes below for the mixed-effect models. I tried several codes online (e.g., effect plot in the PROC PLM) but unable to generate the plots. Ideally, the plot will show timepoints at x-axis, pi/pdi at y-axis (they are the same measurement related at two points), and different lines representing two groups (variable BRIGHT).
DATA Mixed1; SET anova_analysis2023; ARRAY A1{*} pit0 pdit2; DO TMP = 1 to 2; TMPV = VNAME(A1{TMP}); AVAL = A1{TMP}; OUTPUT; END; RUN; PROC MIXED DATA = Mixed1; CLASS ID TMP(ref="1") BRIGHT(ref="0") POC/*IF CATEGORICAL COVARIATES ADD HERE*/; MODEL AVAL = TMP|BRIGHT POC other_op_inlife_t0/*IF CONTINUOUS COVARIATES HERE*/ / S E1 E2; REPEATED TMP / SUBJECT = ID TYPE = UN RCORR; LSMEANS TMP TMP*BRIGHT / CL DIFFS; TITLE1 “Mixed Model (Interaction) between group (BRIGHT) and Time”; RUN;
Some of the codes I have tested are as follows. Maybe I need to combine pit0 and pdit2 into one variable? Thanks for any advice.
proc plm restore=PIPDIModel; /* use item store to create fit plots */ effectplot fit(x=TMP plotby=BRIGHT); /* panel */ effectplot slicefit(x=TMP sliceby=BRIGHT); /* overlay */ run; proc sgplot data=Mixed1; scatter x=TMP y=AVAL / group=BRIGHT; series x=TMP y=AVAL / groupLC=BRIGHT curvelabel; legenditem type=line name="E" / label="Experiment" lineattrs=GraphData1; legenditem type=line name="C" / label="Control" lineattrs=GraphData2(pattern=dash); keylegend "E" "C"; run;
Hey so the dataset anova_analysis2023 is not included in the post. Hope this link helps https://blogs.sas.com/content/iml/2018/12/19/visualize-mixed-model.html
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.