DATA Step, Macro, Functions and more

Having both header image and "Page X of Y" label via ODS PDF

Reply
Contributor
Posts: 29

Having both header image and "Page X of Y" label via ODS PDF

Hello! So I'm trying to edit some pre-written SAS codes for a client who insists that I add the "Page X of Y" format to the PDF outputs. At first, my test runs adding "footnote 'Page ^{thispage} of ^{lastpage}';" made the header image disappear. The closest lead I found to addressing it was through one of the past threads here via <https://communities.sas.com/t5/SAS-Enterprise-Guide/ODS-PDF-stopped-showing-title-image/td-p/45210>.

 

I'm currently using SAS 9.4. I wish the codes I'm working on were as simple as the sample one in <http://support.sas.com/kb/34/573.html>, but they're not since it's a chain of codes calling on each other via %INCLUDE plus there are more than one dataset behind each PDF being produced. Are there any other alternatives to get that " of Y" in "Page X of Y"? Maybe involve PROC TEMPLATE with STYLE FOOTER FROM <something> and POSTTEXT= option?

 

That chain of codes already involve this PROC TEMPLATE:

proc template;

define style styles.test;

parent=styles.printer;

style body from document /

leftmargin=0.75in

rightmargin=0.75in

topmargin=0.75in

bottommargin=0.75in;

end;

run;

Super User
Posts: 11,343

Re: Having both header image and "Page X of Y" label via ODS PDF

You should include part of the code that is supposed to display the image. That might let us know if the method you are using conflicts.

With a complex system you should be able to reduce it to just the code needed and provide an example data set as needed.

 

Or it may be that with many %include files one is setting something incompatible and its going to take some serious sleuthing to find an offending file.

 

It may be that the process should be modified to 1) create all of the data sets and 2) then create the PDF output. Interleaved processes make cleaning up dependencies much harder.

Contributor
Posts: 29

Re: Having both header image and "Page X of Y" label via ODS PDF

I think I figured it out where turning on the OPTIONS statement would prevent the log file you'd need through PROC PRINTTO. It worked after commenting out the OPTIONS MPRINT MLOGIC SYMBOLGEN ...; statements in the code I was revising to sandwich all the steps and ODS PDF TEXT statements in the ...:

/* Start with a clean SAS Log. */
dm "cle log;";

/* Create the PDF file initially to extract the number of pages. */
ods escapechar="^";
filename test "c:\temp\file.log";

/* Direct the SAS Log file to a text file with PROC PRINTTO. */
proc printto log=test new; 
run;

ods noresults;
ods pdf file="file.pdf";

...

ods pdf close;
ods results;

proc printto;
run;

 

Now the last hiccup remaining is that the page number mentioned in the "NOTE: ODS PDF printed <Y> pages to ..." can be off by a page from the PDF.  For example in a couple PDFs I outputted, it may say "NOTE: ODS PDF printed 7 pages to C:\temp\file.pdf" in the log but the PDF file is actually 6 pages which can make the workaround label the last page as "Page 6 of 7" when I would need "Page 6 of 6".  Is there a fix for this?

Contributor
Posts: 29

Re: Having both header image and "Page X of Y" label via ODS PDF

Never mind. Just noticing there can be subtle differences between STARTPAGE=NO and STARTPAGE=NEVER.

Ask a Question
Discussion stats
  • 3 replies
  • 241 views
  • 0 likes
  • 2 in conversation