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.
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.
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.
Okay, two more questions:
1. What version of SAS are you using?
2. Are you generating these bar-line charts using a BY-group?
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.
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.
Thanks Dan for the code sample I will try that and get back to you .
Hi Dan,
Sgpanel doesn't support y2axis I am getting error at series statement?
Thanks,
Sundeep.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.