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

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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