Hello experts,
I am using proc sgplot to graph and sending my output, which is multiple graphs in one page to PDF, however, when I run the code the graphs are placed vertically instead of horizontally. I am obviously doing something wrong. Please see my code below.
ods _all_ close;
ods pdf file="&path/tasks/stl_conf/conf_new/report9.pdf" style=calibri startpage=never notoc dpi=300;
ods graphics / reset=all height=3in width=4in;
ods layout gridded columns=2;
proc sgplot data=hist2.pop_by_age1 noautolegend;
styleattrs datacolors=(BIB VLIGB) datacontrastcolors=(gray);
vbarparm category=Age_group response=Delta_Age /group=group groupdisplay=cluster fillpattern
limitlower=L_Age limitupper=U_Age limitattrs=(color=vipr);
title 'Change by Age';
yaxis label='change';
xaxis label='Age';
run;
proc sgplot data=hist2.age25_above1 noautolegend;
styleattrs datacolors=(BIB VLIGB) datacontrastcolors=(gray);
vbarparm category=educational_attainment response=Delta_25_above / group=group groupdisplay=cluster fillpattern
limitlower=L_Ed limitupper=U_Ed limitattrs=(color=vipr);
title "Change by Educational attainment for 25 Years and Above";
yaxis label='change';
xaxis label='Level of educational attainment';
run;
ods pdf close;
ods preferences;
ods layout end;
Did you try changing your graph sizes.
A page is 8.5x11 and your graphs are 4 inches wide so that is likely causing issues. You also want to move some lines of your code around - layout end should go before ODS PDF CLOSE most likely.
Try this, instead of layout, use the columns option on ODS PDF statement.
ods _all_ close;
ods pdf file="&path/tasks/stl_conf/conf_new/report9.pdf" style=calibri startpage=never notoc dpi=300 columns=2;
ods graphics / reset=all height=3in width=4in;
proc sgplot data=hist2.pop_by_age1 noautolegend;
styleattrs datacolors=(BIB VLIGB) datacontrastcolors=(gray);
vbarparm category=Age_group response=Delta_Age /group=group groupdisplay=cluster fillpattern
limitlower=L_Age limitupper=U_Age limitattrs=(color=vipr);
title 'Change by Age';
yaxis label='change';
xaxis label='Age';
run;
proc sgplot data=hist2.age25_above1 noautolegend;
styleattrs datacolors=(BIB VLIGB) datacontrastcolors=(gray);
vbarparm category=educational_attainment response=Delta_25_above / group=group groupdisplay=cluster fillpattern
limitlower=L_Ed limitupper=U_Ed limitattrs=(color=vipr);
title "Change by Educational attainment for 25 Years and Above";
yaxis label='change';
xaxis label='Level of educational attainment';
run;
ods pdf close;
If you want to stick with layout try changing your graph sizes to see if they go side by side. If they do, I think you need to then adjust your margins to make sense.
@michokwu wrote:
Hello experts,
I am using proc sgplot to graph and sending my output, which is multiple graphs in one page to PDF, however, when I run the code the graphs are placed vertically instead of horizontally. I am obviously doing something wrong. Please see my code below.
ods _all_ close; ods pdf file="&path/tasks/stl_conf/conf_new/report9.pdf" style=calibri startpage=never notoc dpi=300; ods graphics / reset=all height=3in width=4in; ods layout gridded columns=2; proc sgplot data=hist2.pop_by_age1 noautolegend; styleattrs datacolors=(BIB VLIGB) datacontrastcolors=(gray); vbarparm category=Age_group response=Delta_Age /group=group groupdisplay=cluster fillpattern limitlower=L_Age limitupper=U_Age limitattrs=(color=vipr); title 'Change by Age'; yaxis label='change'; xaxis label='Age'; run; proc sgplot data=hist2.age25_above1 noautolegend; styleattrs datacolors=(BIB VLIGB) datacontrastcolors=(gray); vbarparm category=educational_attainment response=Delta_25_above / group=group groupdisplay=cluster fillpattern limitlower=L_Ed limitupper=U_Ed limitattrs=(color=vipr); title "Change by Educational attainment for 25 Years and Above"; yaxis label='change'; xaxis label='Level of educational attainment'; run; ods pdf close; ods preferences; ods layout end;
Thanks for the feedback. Cynthia's option worked.
Thank you!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.