Help using Base SAS procedures

Adding page number in SAS table

Reply
Contributor L_L
Contributor
Posts: 56

Adding page number in SAS table

Dear

inside a statistical report (rtf file), I would like to add the page number in SAS tables: it's useful in tables which are split in more pages.

Thanks in advance for any help

Kind regards

Super User
Super User
Posts: 7,401

Re: Adding page number in SAS table

Sorry, what do you mean?  Page numbers are normally calculated by Word in the footnote by using:

footnote1 j=r "Page ^{thispage} of ^{lastpage}";

This is easier than calculating it your self.

If however you have to have page numbers in the data then you would need to do:

Work out how many pages there will be once rendered - this may not be the same as you think bearing in mind word wrapping/style/borders page size/line size etc.  Then you add that info into your data and output per any other data.  With graphs for instance it may be easy:

data _null_;

     set graph parameters;

     call execute('footnote1 j=r "Page '||strip(put(_n_,best.))||' of ||'strip(put(tot,best.))'||";');

...

run;

For tables and listings you could be in for whole mess of coding.

Contributor L_L
Contributor
Posts: 56

Re: Adding page number in SAS table

Thanks. I'm referring to the number in red in the file attacched (example_sas.doc).

Kind regards

Super User
Super User
Posts: 7,401

Re: Adding page number in SAS table

Yes, not sure what proc output that's generated from but myself I would do:

report to rtf with:

ods escapechar='^';

footnote1 j=r "Page ^{thispage}";

Then print the rtf to pdf.  You could however go directly to PDF with the same syntax.  Me, I would also put a breaking section in the report to get a clean break.  So:
data mydata;

     set mydata;

     retain pge;

     if _n_=1 then pge=1;

     if _n_ = 20 then pge=pge+1;

run;

proc report data=mydata;

     columns pge ...;

     define pge / order noprint;

...

     break after / pge;

...

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