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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1790 views
  • 0 likes
  • 2 in conversation