BookmarkSubscribeRSS Feed
SpongeEvan
Calcite | Level 5

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;
1 REPLY 1
Seadrago
Obsidian | Level 7

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

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 656 views
  • 0 likes
  • 2 in conversation