I want my PDF output to have a footnote like "Page X of Y". I can use the following footnote statement, and it works fine in PC SAS 9.4M8, but it fails in SAS Studio 3.8 with SAS 9.4M6 as the backend:
footnote 'Page (*ESC*){thispage} of (*ESC*){lastpage}';
Here's a full example:
ods pdf file="page number test.pdf";
footnote1 '(1) Page (*ESC*){thispage} of (*ESC*){lastpage}'; * fails in SAS Studio;
footnote2 '(2) Page (*ESC*){thispage}'; * works in SAS Studio;
footnote3 '(3) Total pages: (*ESC*){lastpage}'; * fails in SAS Studio;
proc print data=sashelp.class;
run;
ods pdf close;
Here's a screenshot of the footnotes in the resulting PDF, created with SAS Studio:
Note that {thispage} works fine, but {lastpage} -- which should resolve to the total number of pages -- does not. I don't know if the problem is with SAS Studio or if it's a bug in SAS 9.4M6 that was fixed by 9.4M8.
A very similar question has been asked before (https://communities.sas.com/t5/SAS-Programming/Page-numbers/td-p/681221), though there's no mention of what SAS UI or backend they're using, and there's no real solution since the problem seemed to disappear for the OP.
Is there a way to get this working in SAS Studio with SAS 9.4M6? My company will be phasing out PC SAS very soon.
Try using this statement before your ODS PDF file= statement:
options printerpath=pdf;
Here's a SASnote for reference:
ODS evolved quickly over the last few maintenance releases so my guess is that it was a bug in M6 that was then fixed in a later release. The way to fix this would be to upgrade your SAS 9.4M6 servers to M8. Perhaps you can ask your SAS administrators if there are any plans to upgrade? FYI, full support for SAS 9.4M6 expires Jan 2025.
Try using this statement before your ODS PDF file= statement:
options printerpath=pdf;
Here's a SASnote for reference:
Thank you! Setting the printerpath option fixed the problem; now the code works correctly in both PC SAS 9.4M8 and in SAS Studio with SAS 9.4M6.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.