I have to plot some mean data by a group.
By default the names in the legend is then the names from the defined group.
Are the anyway you can refer to a another variable for to appear in the name in the legend.
As an axample below: I want to plot the sashelp.cars dataset and instead of having grouping variable MAKE
in the names legend I want to refer to the variable ORIGIN
Is that posible (sorry, not the most meanigfull example) ?
proc summary data=sashelp.cars (obs=20) nway; class make; var EngineSize Length; id origin; output out=plotds mean=avg_eng avg_len ; run; proc sgplot data=plotds; scatter x=avg_eng y=avg_len / group=make ; run;
Do you mean something like this?
Make and Origin may not have similar number of levels.
May be better to just label the Origin on each marker.
proc summary data=sashelp.cars (obs=20) nway;
var EngineSize Length;
output out=plotds mean=avg_eng avg_len ;
ods graphics / reset attrpriority=none;
proc sgplot data=plotds nocycleattrs;
scatter x=avg_eng y=avg_len / group=origin name='a' markerattrs=(size=10) ;
scatter x=avg_eng y=avg_len / group=make datalabel=make markerattrs=(size=10) ;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.