BookmarkSubscribeRSS Feed
bkanumuri
Calcite | Level 5

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?

2 REPLIES 2
ed_sas_member
Meteorite | Level 14

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;

 

Rick_SAS
SAS Super FREQ

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"

 

sas-innovate-white.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.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2081 views
  • 0 likes
  • 3 in conversation