BookmarkSubscribeRSS Feed
ColeG
Obsidian | Level 7

I am trying to create a PDF report with multiple pages, one graph per page, each page numbered (should be 6 pages at the end). I need to use ODS layout so that I can position titles and footnotes, but I can't figure out how to get multiple pages in the PDF. If I make the ODS region taller I can get two graphs on one page, but can't get multiple pages. It will only create one page, and the footnote says "page 1 of 1," although the PDF bookmarks shows all of the by values, even though only the first one can be seen. My code (using the class dataset instead of my real data) is below.

 

Any help would be appreciated!

data class; set sashelp.class; run;
proc sort data=class; by sex; run;
title; options orientation=portrait nodate nonumber topmargin=0.25in leftmargin=0.25in rightmargin=0.25in nobyline; ods pdf file ="C:\TestPDF.pdf" uniform startpage=yes nogtitle;
ods graphics on / reset=all border=off width=8in height=4.5in scale=on;
ods layout start; ods region x=20pct y=3pct width=60pct height=8pct; ods pdf text="^S={just=c font_size=11pt font_weight=bold font_face=verdana} This is my descriptive title"; ods region x=11pct y=11pct width=78pct height=50pct; proc sgplot data=class noautolegend noborder nowall; title1 font='Verdana' height=12pt '#byval1'; by sex; vbar name / response=age dataskin=pressed fillattrs=(color='#8BC742'); xaxis display=(nolabel noticks) valueattrs=(family='Verdana' size=9pt); yaxis display=(nolabel) grid gridattrs=(color=verydarkgrey thickness=0.5) valueattrs=(family='Verdana' size=9pt) display=(noline noticks); run; ods region x=94pct y=94pct width=12pct height=2pct; ods pdf text="^S={font_size=8pt font_face=verdana} Page ^{thispage} of ^{lastpage}";
ods layout end; ods pdf close;
3 REPLIES 3
ballardw
Super User

First thing I would try is STARTPAGE=BYGROUP instead of YES.

 

I don't see any footnote or title statements. What I see is use of ODS text to write lines instead of titles and not seeing anything in the example that can't be done with a title statement.

ColeG
Obsidian | Level 7

Thank you--I have never seen any STARTPAGE options besides yes, no, now, and never. However, setting it as STARTPAGE=BYGROUP still only results in one page of output.

 

I have one title in the SGPLOT procedure, '#byval'. Apart from that, yes, I prefer to use ODS text because I find it more flexible and because I can guarantee identical title/subtitle/footnote locations and formats across all PDF reports that I produce regardless of whether I'm producing tables, graphs, or lists.

ballardw
Super User

@ColeG wrote:

Thank you--I have never seen any STARTPAGE options besides yes, no, now, and never. However, setting it as STARTPAGE=BYGROUP still only results in one page of output.

 

I have one title in the SGPLOT procedure, '#byval'. Apart from that, yes, I prefer to use ODS text because I find it more flexible and because I can guarantee identical title/subtitle/footnote locations and formats across all PDF reports that I produce regardless of whether I'm producing tables, graphs, or lists.


Interactions between startpage and layout instructions are not my forte and I seldom work with pdf. This does place the graphs on different pages so the layout is interacting with the startpage settings.. However this also raises the issue that ODS Text is treated as a separate table and hence is a different "by group".

That might be addressable with combinations of ods pdf startpage=no; and ods pdf startpage= now (or by group). but I'm not going to spend a lot of time trying it.

options orientation=portrait nodate nonumber topmargin=0.25in leftmargin=0.25in rightmargin=0.25in nobyline;
ods pdf file ="C:\TestPDF.pdf" uniform startpage=bygroup nogtitle;
ods graphics on / reset=all border=off width=8in height=4.5in scale=on;
ods pdf text="^S={just=c font_size=11pt font_weight=bold font_face=verdana} This is my descriptive title";

proc sgplot data=work.class noautolegend noborder nowall;
 title1 font='Verdana' height=12pt '#byval1';
 by sex;
 vbar name / response=age dataskin=pressed fillattrs=(color='#8BC742');
    xaxis display=(nolabel noticks) valueattrs=(family='Verdana' size=9pt);
    yaxis display=(nolabel) grid gridattrs=(color=verydarkgrey thickness=0.5) valueattrs=(family='Verdana' size=9pt) display=(noline noticks);
run;

ods pdf text="^S={font_size=8pt font_face=verdana} Page ^{thispage} of ^{lastpage}";
ods pdf close;

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
  • 3 replies
  • 860 views
  • 0 likes
  • 2 in conversation