The SAS Output Delivery System and reporting techniques

ods pdf reporting without page breaks

Reply
Occasional Contributor
Posts: 10

ods pdf reporting without page breaks

dear community,
i am using SAS 9.2 and i am trying to make a pdf output of several procedures (proc print, proc gchart) on one page. i do specify "startpage=never" or "startpage=no", and in this case the proc print procedures follow each other without any space between them, so that their titles are lost. each proc gchart still fills the whole page.
i have tried to use "ods layout" and to define regions, but also in this case all my titles were lost.
do somebody know what i am doing wrong, or is there a better solution to produce a pdf without page breaks?

tie script is quite simple:
ods pdf file='C:\Users\report.pdf' startpage=no;
title1 "Age"; proc print data=test noobs; vare age; run;
title1 "Gender"; proc print data=test noobs; vare gender; run;
title1 "Gender"; proc gchart data=test; hbar gender; run;
ods pdf close;
SAS Employee
Posts: 50

Re: ods pdf reporting without page breaks

I can help with this. First a couple of explanations to help understand why things are placed where they are.

In PDF there is one title per page. Trying to put multiple titles above each proc step won't work. In situations like this you need to use ODS PDF TEXT statements to put out lines of text between procs.

Graphs by default will ask for a page break and use an entire page for its output. Using goptions (graph options) and setting hsize (horizontal) and vsize (vertical) will tell the graph object what size you want it to have.

Startpage = no is the perfect way to tell ODS that you want as much output as possible on a page. But if the output exceeds one page it will page break as needed to get all your output to display. So if your tables are not static you might have to readjust based on their new size.

Here is some quick code I put together that I think will help in solving your problem:

ods escapechar = '^';
goptions reset=all hsize=7in vsize=2in;
title;
ods pdf file='report.pdf' startpage=no;
ods pdf text = "^{style [just=center] Age}";
proc print data=sashelp.class(obs=10) noobs; var age; run;
ods pdf text = "^{newline 4}";
ods pdf text = "^{style [just=center] Gender}";
proc print data=sashelp.class(obs=10) noobs; var sex; run;
ods pdf text = "^{newline 4}";
ods pdf text = "^{style [just=center] Gender}";
proc gchart data=sashelp.class; hbar sex; run;
ods pdf close;

After seeing the output you might want to add some fancy inline formatting to your text statements to add color or maybe a different font.

Scott Message was edited by: ScottH@SAS
Occasional Contributor
Posts: 10

Re: ods pdf reporting without page breaks

Dear Scott, thank you very much. This helps a lot.
Emin
Ask a Question
Discussion stats
  • 2 replies
  • 4808 views
  • 1 like
  • 2 in conversation