How to get page numbers in page X of Y format in ODS RTF


In SAS 9 and later, the experimental in-line formatting function {PAGEOF}, produces page X of Y numbering with Word 2000 and higher. Prior to SAS 9, you can add raw RTF code in the TITLE or FOOTNOTE statement. Below is an example of both. 

      /* SAS 8.2 */
   /* CAUTION: Make sure the raw RTF code is on ONE line */
   ods listing close;
   options nonumber;
   ods rtf file="temp.rtf";
   proc print data=sashelp.retail;
    footnote j=r
     "{\field{\*\fldinst{\b\i PAGE}}}\~{\b\i of}\~{\field{\*\fldinst{\b\i NUMPAGES}}}";
   run;
   ods rtf close;

   /* SAS 9.0 and later */
   ods listing close;
   options nonumber;
   ods escapechar="^";
   ods rtf file="temp.rtf";
   proc print data=sashelp.retail;
    footnote j=r "^{pageof}";
   run;
   ods rtf close;
  

See more information about PROC TEMPLATE and the RTF destination.