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-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
  • 2 replies
  • 1469 views
  • 0 likes
  • 3 in conversation