Help using Base SAS procedures

sgplot with proc greplay

Reply
Contributor
Posts: 24

sgplot with proc greplay

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.

Super User
Super User
Posts: 7,392

Re: sgplot with proc greplay

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.

Contributor
Posts: 24

Re: sgplot with proc greplay

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.

SAS Super FREQ
Posts: 8,739

Re: sgplot with proc greplay

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;

Contributor
Posts: 24

Re: sgplot with proc greplay

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.

Super User
Super User
Posts: 7,392

Re: sgplot with proc greplay

Try layout lattice per: http://blogs.sas.com/content/graphicallyspeaking/2013/02/12/gtl-layouts/

That even shows common legend.

SAS Super FREQ
Posts: 8,739

Re: sgplot with proc greplay

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;

Contributor
Posts: 24

Re: sgplot with proc greplay

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

Super User
Super User
Posts: 7,392

Re: sgplot with 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.

Ask a Question
Discussion stats
  • 8 replies
  • 781 views
  • 0 likes
  • 3 in conversation