Hi All,
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.
Hi,
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.
Thanks for the response. I am trying to create 4 bar line charts with common legend I dont see any similar thing in that article.
Hi:
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...?
Cynthia
** run the code once with the KEYLEGEND statement and then;
** run it again without and you should see what the KEYLEGEND statement does;
ods listing;
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';
run;
Hi Cynthia
It is 4 graphs in one pdf page which need to have one common legend for all the 4 graphs .Not 4 lines and one bar in one graph.
Try layout lattice per: http://blogs.sas.com/content/graphicallyspeaking/2013/02/12/gtl-layouts/
That even shows common legend.
Hi, Sounds like PROC SGPANEL to me. You can easily get 4 graphs on 1 page in a PDF file with 1 legend.
Cynthia
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');
panelby product;
vbar region / response=sales stat=mean group=region;
run;
ods pdf close;
Hi Cynthia,
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.
41461 - Put multiple PROC SGPLOT outputs on the same PDF page using PROC GREPLAY
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.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.