BookmarkSubscribeRSS Feed
BigPete
Obsidian | Level 7

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;

3 REPLIES 3
ballardw
Super User

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.

BigPete
Obsidian | Level 7

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?

BigPete
Obsidian | Level 7

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

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
  • 1176 views
  • 0 likes
  • 2 in conversation