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"

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2400 views
  • 0 likes
  • 3 in conversation