DATA Step, Macro, Functions and more

Need to get "Page of total pages".

Reply
Occasional Contributor
Posts: 18

Need to get "Page of total pages".

hi there,

I am writing a macro for proc report with RTF output.

I need to report in such a way that if there are more than 4 columns then rest would be reported in next page.  Thus if there are 6 columns then two pages would be there.

&lst is number of columns. 

%do i=1 %to &lst;

  %if &i=4 %then %do;

  define v&i / display width=15 " %sysfunc(strip(var&i)) * %sysfunc(strip(&&var&i)) * N=%sysfunc(strip(&&a&i))* n (%) "style=[just=Center]page;

  %end;

  %else %do;

  define v&i / display width=15 " %sysfunc(strip(var&i)) * %sysfunc(strip(&&var&i)) * N=%sysfunc(strip(&&a&i))* n (%) "style=[just=Center ];

  %end;

  %end;

With above code, I am able to generate report of two pages successfully if I have more than 4 columns.

But the problem is I am getting "page 1 of 1" in 1st page footnote and "page 2 of 2" on second page footnote. But I need is page 1 of 2 and  page 2 of 2.

I am using "Page ~{pageof}" to get page number.

Super User
Posts: 17,912

Re: Need to get "Page of total pages".

How is what you want different?

There's also {thispage} I believe.

Occasional Contributor
Posts: 18

Re: Need to get "Page of total pages".

I am getting "page 1 of 1" instead of "page 1 of 2". By the way, How would you use {thispage} .Caould you give me an example.

SAS Super FREQ
Posts: 8,744

Re: Need to get "Page of total pages".

Hi, Sometimes, Word is not cooperative. Frequently, you need to switch into Print Preview mode or you need to scroll to the bottom of the document and back up to the top in order for the page numbers to refresh. I have even seen the page numbers appear as Page 2 of 1 in the Word doc -- although that was back in Office 2003, but usually, paging down or forcing pagination fixed the issue and got Word straightened out. ODS ESCAPECHAR and {pageof} work by inserting Word specific "field codes" into the RTF file. Sometimes you have to get Word's attention to make it paginate correctly.

cynthia

Super User
Posts: 17,912

Re: Need to get "Page of total pages".

This is for PDF and I want the number to start at 47.

options pageno=47;

ods escapechar="^";

ods pdf file="C:\temp\temp.pd" style=journal;

options nonumber nodate;

title 'Example of page number';

footnote j=l "^{style [just=l fontsize=9pt fontstyle=roman fontweight=light] ^{unicode 00A9} Reeza}" j=r "^{style [fontsize=9pt fontstyle=roman fontweight=light]^{thispage}";

proc print data=sashelp.class;

run;

ods pdf close;

Ask a Question
Discussion stats
  • 4 replies
  • 223 views
  • 6 likes
  • 3 in conversation