Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
joesmama
Obsidian | Level 7

Hello, 

 

Using SGPLOT for the first time and need help figuring out how to adjust/compress  the Y-axis so that the legend can appear on the graph. As of now, the legend is absent from the graphs. I;ve looked through the documentation but haven't found anything that specifically addresses this. Any and all ideas are appreciated. 

 

proc sgplot data=survplot4;
step x=time y=survival / group=stratum name='s';
xaxis min=0 max=360 values=(0 to 360 by 60); title 'Survival in Months';
yaxis min=0 max=1 values=(0 to 1 by 0.1);
keylegend 's' / linelength=20;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
JeffMeyers
Barite | Level 11
Did you try setting ODS GRAPHICS / reset MAXLEGENDAREA=100; ? If that doesn't fix it then I would try running your original data through the LIFETEST procedure and grab the graph from there, and then post the picture here so we can see exactly how long your labels are and if there's some funny characters in there you're not seeing.

View solution in original post

6 REPLIES 6
DanH_sas
SAS Super FREQ

On the ODS GRAPHICS statement, specify a larger LEGENDAREAMAX value. The default is 20% of your graph space. After that, the legend is dropped. Here is the doc for the option: https://go.documentation.sas.com/?docsetId=grstatproc&docsetTarget=p0kroq43yu0lspn16hk1u4c65lti.htm&...

joesmama
Obsidian | Level 7
Thank you for the reference.
ballardw
Super User

How long is the text displayed in the legend for your group variable STRATUM? I normally would not expect 20 groups to exceed the default area for a legend but if your text values are long I would also suggest considering if the current text could be reduced.

joesmama
Obsidian | Level 7

Thank you for your response.

 

I have 8 groups in my strata. I have shortened the names but still am not able to get the legend to appear. As well, I've tried adjusting the items suggested in the log to no avail. 

 

NOTE: Some graph legends have been dropped due to size constraints. Try adjusting the MAXLEGENDAREA=,
WIDTH= and HEIGHT= options in the ODS GRAPHICS statement.

 

As well, I've tried adjusting the items suggested in the log to no avail. The legend remains absent.  My other graphs using the same data run nicely, ust not this particular graph. I'm not sure how to proceed. Do you have further recommendations? Thank you. 

 

 

JeffMeyers
Barite | Level 11
Did you try setting ODS GRAPHICS / reset MAXLEGENDAREA=100; ? If that doesn't fix it then I would try running your original data through the LIFETEST procedure and grab the graph from there, and then post the picture here so we can see exactly how long your labels are and if there's some funny characters in there you're not seeing.
joesmama
Obsidian | Level 7

That did the trick!. I wasn't using "reset" before MAXLEGENDAREA. 

 

Many thanks. 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 5032 views
  • 1 like
  • 4 in conversation