I am trying to create spaghetti plots by treatment groups using PROC SGPANEL with each treatment group as one panel (side by side.)
I am able to get that but it creates 1 legend with all the subjects (subjects from both the treatment groups). Is there a way to create a separate legend one for each panel listing the subjects in the respective panel/treatment group?
Hi @bkanumuri
Assuming a subject (subject) has one result (result) per timepoint (time) and belong to one of the arms (trt_group), you can try this:
Each group will have one specific color (through the keylegend statement). The subject id will be displayed on each curve (curvelabel option). Does that answer you question?
proc sgplot data=one;
title 'Study Results by Treatment Group';
series x=time y=results / group=subject grouplc=trt_group name='grouping' curvelabel;
keylegend 'grouping' / type=linecolor;
run;
I do not know how to create separate legends inside each cell in PROC SGPANEL. However, you can use PROC SGPLOT with a BY statement and then use ODS LAYOUT GRIDDED statement to arrange the plots into a panel. See
"Using the ODS statement to add layers in your ODS sandwich"
and
"Arrange matrices and graphs in a gridded layout"
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.