BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
magicdj
Obsidian | Level 7

 

i have similar situation in link below. my question is this is individual plot with many lines.

but for legend, i just want to specify the color by group.

for example, in FreelanceReinh Jade's post: 

series x=avisit y=aval / group=usubjid attrid=myid;

 for legend, instead of list usubjids, just want to list legend as blue for trta='A' and red for trta='B'. how do i do that? thanks.

 

Solved: How Can I Specify Line Colors per Group in SG Plot? - SAS Support Communities

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

You need to use a secondary classifier on the SERIES plot, and tell the legend to show only the line color. Here is an example using the data from the other post:

 

data test;
    input usubjid$ trta$ avisit$ aval;
    datalines;
    xx-01 A Day1 10
    xx-01 A Day5 11
    xx-02 A Day1  9
    xx-02 A Day5 10
    xx-03 B Day1 20
    xx-03 B Day5 17
    xx-04 B Day1 19
    xx-04 B Day5 21
    ;
run;
proc sgplot data=test;
    series x=avisit y=aval / group=usubjid grouplc=trta;
    keylegend / type=linecolor title="TRTA";
run;

 

 

View solution in original post

1 REPLY 1
DanH_sas
SAS Super FREQ

You need to use a secondary classifier on the SERIES plot, and tell the legend to show only the line color. Here is an example using the data from the other post:

 

data test;
    input usubjid$ trta$ avisit$ aval;
    datalines;
    xx-01 A Day1 10
    xx-01 A Day5 11
    xx-02 A Day1  9
    xx-02 A Day5 10
    xx-03 B Day1 20
    xx-03 B Day5 17
    xx-04 B Day1 19
    xx-04 B Day5 21
    ;
run;
proc sgplot data=test;
    series x=avisit y=aval / group=usubjid grouplc=trta;
    keylegend / type=linecolor title="TRTA";
run;

 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 1 reply
  • 673 views
  • 4 likes
  • 2 in conversation