07-21-2014 08:24 AM
I am trying to create multilple graph with common legend. I got multilple graphs in to the pdf but I am stuck on how to create a common legend for sgplot . I got an example for gplot tp create a common legend but not forsgplot. Can anyone help me on this.Thanks in advance.
07-21-2014 08:28 AM
Have a look through this blog: http://blogs.sas.com/content/graphicallyspeaking/
It has examples of pretty much anything you can think of doing with graphs, generally provides sgplot and GTL code for each one. GTL is probably easier.
07-21-2014 08:55 AM
This might be better posted in the Graph forum. But I can easily control the legend when I run this code. I guess I don't understand what you mean by 4 "bar line" charts -- 1 bar and 4 lines? or...?
** run the code once with the KEYLEGEND statement and then;
** run it again without and you should see what the KEYLEGEND statement does;
proc sgplot data=sashelp.shoes;
vbar product / response=returns stat=mean name='bar';
vline product / response=inventory stat=mean name='inv' y2axis;
vline product / response=sales stat=mean name='sal' y2axis;
keylegend 'inv' 'sal';
07-21-2014 06:18 PM
Hi, Sounds like PROC SGPANEL to me. You can easily get 4 graphs on 1 page in a PDF file with 1 legend.
ods pdf file='c:\temp\_4graf.pdf';
proc sgpanel data=sashelp.shoes;
where (product contains 'Dress' or
product contains 'Casual') and
region in ('Asia', 'Pacific', 'Canada');
vbar region / response=sales stat=mean group=region;
ods pdf close;
07-22-2014 12:31 AM
Its not a sgpanel procedure as I am creating a bar line chart I used Proc sgplot. It is similar to the below example but the only thing is I am not getting the common legend.
07-21-2014 09:00 AM
Not the top article in particular, it is a blog, so has many posts on different subjects. You should however find an example there, try the search box for Legend, has many examples.