Search code examples
pdfsassas-ods

sas page footnote in ods pdf


I'd like to have a page number in the format of "X OF Y PAGES" at the right bottom of each page. I tried the following code for a pdf result but it's just displaying "Page *{thispage} of &num" literally. Can anyone help with this? Thanks!

* create the file with the number of pages */

ods results;

ods pdf file="c:\temp\pagenumb.pdf" compress=0;

footnote j=r "Page *{thispage} of &num";

%pdf_code;

ods pdf close;

Solution

  • You're pretty close in your attempt. I'll do it like this:

    For example:

    options nodate nonumber;
    data work.animals;
        input name $ weight;
        datalines;
        monkey 20
        shark 500
        lion 200
        wolf 120
        buffalo 400
        ;
    run;
    
    ods pdf file = 'C:\sasdata\animals.pdf';
    ods escapechar= '!';
    proc print data=work.animals;
        title 'Animals';
        footnote j = r 'Page !{thispage} of !{lastpage}';
    run;
    ods pdf close;
    ods listing;
    

    Basically I chose to use an exclamation mark "!" for my escape character as a way to grab SAS's attention. Then we can use a foot note with right justification since we want it on the bottom right hand side (j = r). We can also use j = l or c or r depending on which side you want the footnote to be on.

    And finally I used ods listing because I don't want to view the output in SAS (I only want to output a pdf file). Cheers.