BookmarkSubscribeRSS Feed
emin_ch
Calcite | Level 5
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;
2 REPLIES 2
ScottH_SAS
SAS Employee
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
emin_ch
Calcite | Level 5
Dear Scott, thank you very much. This helps a lot.
Emin

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 14016 views
  • 1 like
  • 2 in conversation