BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fri0
Quartz | Level 8

Hi, I'm using EG 7.12 and I have a problem when I use markerattrs. (NBRSUCAGE is the variable with the label names for the graph legend)

 

Using this code, the legend appears:

proc sgplot data=stats.cuadro; 
scatter x=var16_17 y=ING17 /group=NBRSUCAGE  name="ag";
discretelegend "ag" / title="Agencias";
title "Variación 2016- 2017 vs Ingresos"; 
run;

graph_legend.jpg

 

But, when I agree the markeratrrbs option, the legend disappears:

 

 

 

proc sgplot data=stats.cuadro; 
scatter x=var16_17 y=ING17 /group=NBRSUCAGE markerattrs=(symbol=circlefilled size=3pct) name="ag";
discretelegend "ag" / title="Agencias";
title "Variación 2016- 2017 vs Ingresos"; 
run;

graph_error.jpg

 

How could I maintain the changes without losing the legend?

Also, It would be a plus if there is any way to have different symbols for markers without coding a previous template. Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

1: What are you trying to accomplish with the DISCRETELEGEND Statement?

 

2: You can use different symbols for markers without coding a previous template by setting the ATTRPRIORITY=NONE in the ODS GRAPHICS Statement and use the STYLEATTRS Statement as in the following small example

 

ods graphics on / attrpriority=none;
proc sgplot data=sashelp.iris noautolegend;
   styleattrs datasymbols=(circlefilled squarefilled starfilled) ;
   scatter x=sepallength y=sepalwidth / group=species;
   keylegend / location=inside position=NE across=1;
run;

 

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

1: What are you trying to accomplish with the DISCRETELEGEND Statement?

 

2: You can use different symbols for markers without coding a previous template by setting the ATTRPRIORITY=NONE in the ODS GRAPHICS Statement and use the STYLEATTRS Statement as in the following small example

 

ods graphics on / attrpriority=none;
proc sgplot data=sashelp.iris noautolegend;
   styleattrs datasymbols=(circlefilled squarefilled starfilled) ;
   scatter x=sepallength y=sepalwidth / group=species;
   keylegend / location=inside position=NE across=1;
run;

 

fri0
Quartz | Level 8
Hi!
1. Justo to show the legend next to the graph, I don't want to have label over the markers. Is there a better way?.
2. Ok, It's needed a previous template. Thanks!
PeterClemmensen
Tourmaline | Level 20

Use the KEYLEGEND Statement and alter the POSITION= and LOCATION= Options to put the legend where you want it

fri0
Quartz | Level 8

Hi draycut, I checked the keylegend statement, got better output, but I have the same problem when I included the markerattrs option. After many changes, I realize that the problem appears when you use pct as measure for the size marker, I changed it to mm and the legend appears. Thanks!!!

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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