ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
michokwu
Quartz | Level 8

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 graphsods startpage=now;ods region;ods graphics/height=5in width=4in;/*Plot Graphs*/
 - proc sgplot procedure for the next set of graphs

 

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelL_SAS
SAS Employee

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. 

View solution in original post

10 REPLIES 10
Reeza
Super User
Do you reset the startpage option after the first graph on the second page?
michokwu
Quartz | Level 8

No, I did not

michokwu
Quartz | Level 8

No, I did not reset the startpage option

Reeza
Super User

Does that fix your problem then?

 


@michokwu wrote:

No, I did not reset the startpage option


 

michokwu
Quartz | Level 8

I just did! did not help

Reeza
Super User
Can you post the code, so we can see what you ran? I'm about 99% sure that works if done correctly but I can't see what you did. You can change the SGPLOT to basic plots using data in SASHELP, they can be all the same if you want.
michokwu
Quartz | Level 8

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.

 

Reeza
Super User
I can't actually take that code and run it though, it won't generate output I can test to see your issue.
michokwu
Quartz | Level 8
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;
MichaelL_SAS
SAS Employee

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. 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 3262 views
  • 0 likes
  • 3 in conversation