Hi all,
I am wondering if there's any way to make the legend title and labels left justified in PROC SGPLOT, because I have a long legend title. Here is the example of my current situation:
I generated this legend using KEYLEGEND statement and put it on the upper left corner. As is shown above, I want to move "<= 5 mg/kg/day" and "> 5 mg/kg/day" to the left, which is to left justify with the legend title "xxxxxxx". Is there any way to do that?
You may need to place the legend with a blank title, and add the title using SGAnnotate.
See Dan's paper: https://support.sas.com/resources/papers/proceedings11/277-2011.pdf
Are you using KEYLEGEND? EDIT: You said you were 🙂
A manual kludged method assuming no one else has a better solution, what happens if you add some trailing spaces at the end of the labels, either spaces or tabs (09)? Does that force it to the left more?
"> 5 mg/kg/day "
@Chaupak wrote:
Hi all,
I am wondering if there's any way to make the legend title and labels left justified in PROC SGPLOT, because I have a long legend title. Here is the example of my current situation:
I generated this legend using KEYLEGEND statement and put it on the upper left corner. As is shown above, I want to move "<= 5 mg/kg/day" and "> 5 mg/kg/day" to the left, which is to left justify with the legend title "xxxxxxx". Is there any way to do that?
You may need to place the legend with a blank title, and add the title using SGAnnotate.
See Dan's paper: https://support.sas.com/resources/papers/proceedings11/277-2011.pdf
I tried using '09'x, but it still didn't work. This link says that the tab character will be converted as blanks when the codes are submitted, when using the enhance editor (if I didn't misunderstand). I think add a legend title manually using annotation may help, like what Jay recommended. Thank you!
As Reeza said ,try TAB character '09'x , NOT blank character.
Another option is to use SAS/Graph Proc Gplot (rather than Base Proc SGplot).
Here's a short example:
legend1 position=(top left inside) across=1
label=(position=top 'xxxxxxxxxxxxxxxxxxxxxx');
symbol value=none interpol=join;
proc gplot data=sashelp.stocks;
plot close*date=stock / legend=legend1;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: