Hello experts,
My SAS output is a collection of graphs, the destination is PDF and the graphs are grouped by 4 per page. After the first page, the the graphs reverts to 1 per page. I used the startpage=now option after the first 4 graphs to signal the beginning of the 2nd page but still have the graphs 1 per page.
I want the graphs to take the format of the 1st page where they are displayed 4 by page.
Thank you.
My code
ods pdf file="&path/tasks/stl_conf/conf_new/report14.pdf" style=calibri startpage=never notoc dpi=300;
title font=Helvetica bold h=10pt "Charts showing the change in variables with confidence interval";
ods layout gridded rows=2 columns=2 column_widths=(3in 3in);
ods region;
ods graphics/height=5in width=4in;
/*Plot Graphs*/
- proc sgplot procedure for the first 4 graphs
ods startpage=now;
ods region;
ods graphics/height=5in width=4in;
/*Plot Graphs*/
- proc sgplot procedure for the next set of graphs
Looks like you have a mismatch between the number of ODS LAYOUT GRIDDED statements (two) and the number of ODS LAYOUT END statements (one), add a second ODS LAYOUT END statement after the fourth graph before starting the second page.
No, I did not
No, I did not reset the startpage option
I just did! did not help
I used the same code as pasted, however, I have been tweaking it to see what works
When I included ods startpage=now/ reset; before the graphs in the 2nd page, it changes the page setup to 2 graphs per page with the graphs overlaying after the 4th graph
When I tried this after the 1st graph on the second page (i.e after the 5th graph) it worked for the remaining graphs on the page but the 5th graph was on a single page. When I tried it before the 1st graph on the second page, the graphs overlay.
ods startpage=now;
ods region;
ods graphics/height=5in width=4in;
/*Plot Graphs*/
- proc sgplot procedure for the next set of graphs
Per your observation, it could be a case of me not applying the code correctly, if you can help with the correct code, that will be helpful.
The original code is included in the post.
Thank you.
options leftmargin=.25in rightmargin=.25
topmargin=.25in bottommargin=.25 number date;
ods pdf file="&path/tasks/stl_conf/conf_new/report18.pdf" style=calibri startpage=never notoc dpi=300;
title font=Helvetica bold h=10pt "Group1 vs Group2: Charts showing the change in variables with confidence interval";
ods layout gridded rows=2 columns=2 column_widths=(3in 3in);
ods region;
ods graphics/height=5in width=4in;
/*Plot age group1*/
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 font=Helvetica bold h=8pt 'Population Change by Age';
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='Age' labelattrs=(size=8pt);
run;
ods region;
ods graphics/height=5in width=4in;
/*Plot age group2*/
proc sgplot data=kansas1.pop_by_age noautolegend;
styleattrs datacolors=(virp parp) datacontrastcolors=(gray);
vbarparm category=var1 response=Delta_Total /group=group groupdisplay=cluster fillpattern
limitlower=L_Total limitupper=U_Total limitattrs=(color=vipr);
title font=Helvetica bold h=8pt 'Population Change by Age';
title 'Kansas City Population Change 2010 to 2017 by Age';
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='Age' labelattrs=(size=8pt);
run;
ods region;
ods graphics/height=5in width=4in;
/*Plot educational attainment - 25years and over1*/
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 font=Helvetica bold h=8pt "Population Change by Educational attainment for 25 Years and Above";
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='Educational attainment' labelattrs=(size=8pt);
run;
ods region;
ods graphics/height=5in width=4in;
/*Plot educational attainment - 25years and over2*/
proc sgplot data=kansas1.edu_attainment noautolegend;
styleattrs datacolors=(virp parp) datacontrastcolors=(gray);
vbarparm category=educational_attainment response=Delta_Total / group=group groupdisplay=cluster fillpattern
limitlower=L_Total limitupper=U_Total limitattrs=(color=vipr);
title font=Helvetica bold h=8pt "Population Change by Educational attainment for 25 Years and Above";
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='Educational attainment' labelattrs=(size=8pt);
run;
ods startpage=now;
ods layout gridded rows=2 columns=2 column_widths=(3in 3in);
ods region;
ods graphics/height=5in width=4in;
/*Plot population by race1*/
proc sgplot data=hist2.race1 noautolegend;
styleattrs datacolors=(BIB VLIGB)datacontrastcolors=(gray);
vbarparm category=race response=Delta_Race / group=group groupdisplay=cluster fillpattern
limitlower=L_Race limitupper=U_Race limitattrs=(color=vipr);
title font=Helvetica bold h=8pt "Population Change by Race";
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='Race' labelattrs=(size=8pt);
run;
ods region;
ods graphics/height=5in width=4in;
/*Plot population by race2*/
proc sgplot data=kansas1.race1 noautolegend;
styleattrs datacolors=(virp parp) datacontrastcolors=(gray);
vbarparm category=race response=Delta_Total / group=group groupdisplay=cluster fillpattern
limitlower=L_Total limitupper=U_Total limitattrs=(color=vipr);
title font=Helvetica bold h=8pt "Population Change by Race";
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='Race' labelattrs=(size=8pt);
run;
ods region;
ods graphics/height=5in width=4in;
/*Plot population by school enrollment1*/
proc sgplot data=hist2.sch_enrollment1 noautolegend;
styleattrs datacolors=(BIB VLIGB)datacontrastcolors=(gray);
vbarparm category=school_enrollment response=Delta_Enrol / group=group groupdisplay=cluster fillpattern
limitlower=L_Enrol limitupper=U_Enrol limitattrs=(color=vipr);
title font=Helvetica bold h=8pt "Population Change by School Enrollment";
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='School Enrollment' labelattrs=(size=8pt);
run;
ods region;
ods graphics/height=5in width=4in;
/*Plot population by school enrollment2*/
proc sgplot data=kansas1.sch_enrollment noautolegend;
styleattrs datacolors=(virp parp) datacontrastcolors=(gray);
vbarparm category=school_enrollment response=Delta_Total / group=group groupdisplay=cluster fillpattern
limitlower=L_Total limitupper=U_Total limitattrs=(color=vipr);
title font=Helvetica bold h=8pt "Population Change by School Enrollment";
yaxis valueattrs=(size=4pt) label='Population change' labelattrs=(size=8pt);
xaxis valueattrs=(size=4pt) label='School Enrollment' labelattrs=(size=8pt);
run;
ods layout end;
ods _all_ close;
Looks like you have a mismatch between the number of ODS LAYOUT GRIDDED statements (two) and the number of ODS LAYOUT END statements (one), add a second ODS LAYOUT END statement after the fourth graph before starting the second page.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.