Hi all,
I used sgplot to create a scatter and series plot. I get two legends as result. How can are supress one since they are both the same.
Hello,
As @Reeza and @DanH_sas said, you can use the KEYLEGEND statement, with the NAME option. Here is an example, that you can use below to understand things better. Also there may not be any use for you to use the SCATTER statement, because you can also use the MARKERS option in the SERIES statement to produce the markers.
data stocks;
set sashelp.stocks;
emphasis = 2;
if stock eq 'Microsoft' then emphasis=1;
run;
title 'Microsoft Compared to IBM and Intel';
proc sgplot data=stocks (where=(date >= "01jan2003"d));
series x=date y=close / group=stock grouplc=emphasis name="leg";
scatter x=date y=close / group=stock;
keylegend "leg";
run;
Use the NAME option on one of the plots, and reference that name from the KEYLEGEND statement (as @Reeza mentioned). That will give you the one legend you want.
Hello,
As @Reeza and @DanH_sas said, you can use the KEYLEGEND statement, with the NAME option. Here is an example, that you can use below to understand things better. Also there may not be any use for you to use the SCATTER statement, because you can also use the MARKERS option in the SERIES statement to produce the markers.
data stocks;
set sashelp.stocks;
emphasis = 2;
if stock eq 'Microsoft' then emphasis=1;
run;
title 'Microsoft Compared to IBM and Intel';
proc sgplot data=stocks (where=(date >= "01jan2003"d));
series x=date y=close / group=stock grouplc=emphasis name="leg";
scatter x=date y=close / group=stock;
keylegend "leg";
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.