BookmarkSubscribeRSS Feed
sundeep23
Obsidian | Level 7

Hi All,

             Using the below link I have created created multiple sgplot output on to one pdf . What I need is to create a common legend . I have tried creating a blank sgplot with legend by making the graph axis values out of range but it didn't worked as it is masking the entire multiple sgplot output. Is there any other way to do it.

41461 - Put multiple PROC SGPLOT outputs on the same PDF page using PROC GREPLAY

Thanks,

Sundeep.

7 REPLIES 7
DanH_sas
SAS Super FREQ

You can put multiple SG outputs on the same PDF page without using GREPLAY. In fact, if you use GREPLAY to do it, you would need to be very careful how you generated the images as to not create image artifacts when putting them into PDF. To help with both this issue and the common legend, it would be helpful to know the types of graphs you're generating, as there might be a simple way to get both to happen is certain situations.

sundeep23
Obsidian | Level 7

Hi Dan ,

                   Thanks for the quick response I am generating a barline chart . I used greplay as I need to create a 3* 3 graph template.

Thanks,

Sundeep.

DanH_sas
SAS Super FREQ

Okay, two more questions:

1. What version of SAS are you using?

2. Are you generating these bar-line charts using a BY-group?

sundeep23
Obsidian | Level 7

Hi Dan,

                   I am using SAS 9.4 and I am not using by variable but group option in the vbarparm.I am not using vbar and vline as I need different group labels.

sample code

proc sgplot data=&inpt.;

where tr= "&FRT.";

vbarparm category=var1 response=cnt / group=grp1 name="a";

series x=var1  y=rt / group=grp2 y2axis name="b";

keylegend "a" "b"  / across=4;

run;

Thanks,

Sundeep.

DanH_sas
SAS Super FREQ

Thanks for the code sample. That really helps. Here is a solution that should give you a 3x3 grid of charts with a common legend on each PDF page. The output is assuming some relationship between each plot:

ods pdf file="temp.pdf";

ods graphics / width=7in height=9.5in; /* allowing for some margins */

proc sgpanel data=&inpt.;

panelby tr / novarname onepanel rows=3 columns=3;

vbarparm category=var1 response=cnt / group=grp1 name="a";

series x=var1  y=rt / group=grp2 y2axis name="b";

keylegend "a" "b"  / across=4;

run;

ods pdf close;

If you do not want the headers, add the NOHEADER option to the PANELBY statement. Give that a try and see if that will work for you.

sundeep23
Obsidian | Level 7

Thanks Dan for the code sample I will try that and get back to you .

sundeep23
Obsidian | Level 7

Hi Dan,

                 Sgpanel doesn't support  y2axis I am getting error at series statement?

Thanks,

Sundeep.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1794 views
  • 0 likes
  • 2 in conversation