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;
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&...
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.
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.
That did the trick!. I wasn't using "reset" before MAXLEGENDAREA.
Many thanks.
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!
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.