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
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;
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.