BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RD2
Fluorite | Level 6 RD2
Fluorite | Level 6

In SAS 9.3  I run the sample code in  http://support.sas.com/kb/24/602.html

Table of content worked. But footnote  Page X of Y not resolved in WORD 2007. Still as following:

{Page}  {field{*fldinst { PAGE }}}~of~{field {*fldinst{ NUMPAGES }}}

 

Anyone can help?

Randy

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  That code uses DATA _NULL_ techniques and there are no FOOTNOTE statements in the code. Did you add a FOOTNOTE statement to the code AND, you also have to add an ODS ESCAPECHAR statement to the code??? And, what do you mean when you say that the TOC did not work? Did you see a (mostly) empty page that had a title of TABLE OF CONTENTS at the top of the empty page? And if you saw the empty page, did you right click and tell Word to update the fields??? With the CONTENTS= option, RTF sends the RTF control codes for creating the TOC, but you must manually go to the first page and tell Word to update the fields to create the TABLE of CONTENTS.

cynthia

View solution in original post

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

Hi:

  I no longer have Office 2007 to work with, but I have used and tested the ODS ESCAPECHAR method of generating Page X of Y in Word 2003, 2007, and 2010. ODS ESCAPECHAR methods DO work in all these versions of Word, whether I use {THISPAGE} and {LASTPAGE} or {PAGEOF} (RTF only). In some instances, Word had to be forced to repaginate in order to see the results; in other instances, I had to switch into Page Preview or Print Preview mode. The only instance where Page X of Y does not work with ODS RTF is when you try to use the BODYTITLE option with the ODS ESCAPECHAR method of generating Page X of Y page numbers.

  Since you did not provide code, I'm not sure what's happened. I would recommend a simple test:

options nodate nonumber;

 

ods listing close;

ods rtf file='testpgno.rtf';

ods escapechar='^';

title j=r 'Title: This is Page ^{pageof}';

footnote j=r 'Footnote: This is Page ^{thispage} of ^{lastpage}';

footnote2 j=r 'Footnote2: -- ^{thispage} --';

  

proc print data=sashelp.shoes noobs;

run;

  

ods rtf close;

If the above test does NOT work for you to get page X of Y page numbering, then I would recommend that you open a track with Tech Support. If the above test DOES work for you, then I would recommend that you compare the above code to your code and adjust your code accordingly.

cynthia

DouglasMartin
Calcite | Level 5

Probably a silly suggestion, but does hitting Alt-F9 in the Word document help?

RD2
Fluorite | Level 6 RD2
Fluorite | Level 6

Dear Cyntia,

Your code worked.  But after I rerun the code in  http://support.sas.com/kb/24/602.html

what strange  are:

1)  There is no Footnote in rtf

2) TOC not worked.

I follow the following instruction:

/* In SAS 9.2 use: ods rtf file='c:\temp\contents.rtf' contents toc_data; */

Randy

Cynthia_sas
SAS Super FREQ

Hi:

  That code uses DATA _NULL_ techniques and there are no FOOTNOTE statements in the code. Did you add a FOOTNOTE statement to the code AND, you also have to add an ODS ESCAPECHAR statement to the code??? And, what do you mean when you say that the TOC did not work? Did you see a (mostly) empty page that had a title of TABLE OF CONTENTS at the top of the empty page? And if you saw the empty page, did you right click and tell Word to update the fields??? With the CONTENTS= option, RTF sends the RTF control codes for creating the TOC, but you must manually go to the first page and tell Word to update the fields to create the TABLE of CONTENTS.

cynthia

RD2
Fluorite | Level 6 RD2
Fluorite | Level 6

Dear Cynthia,

Right click do the trick for TOC.

I guess the footnote problem is because template overwrite by other program when I run the sample code.

Thanks!

Cynthia_sas
SAS Super FREQ

Hmmm...well, I ran the sample program, with a footnote statement and an ODS ESCAPECHAR statement and using Page X of Y functions in the footnote and in Office 2010, I got the right page numbers when I ran the code. As I said, I have used Page X of Y in my code with Office 2003, Office 2007 and Office 2010. I'd recommend that you work with Tech Support -- there's nothing I can think of in the template that would interfere with the page numbers. Tech Support can look at all your code and test opening the output in the version of Word that is the same as yours.

cynthia

** here is the code I used to create the screenshot taken in Word 2010;

** the attached screenshot shows the bottom of page 2 and the top of page 3;

options nodate nonumber;

ods escapechar='^';

ods listing close;

          

ods rtf file='c:\temp\data_step_contents.rtf'

    contents toc_data;

        

footnote j=r 'Footnote: This is Page ^{thispage} of ^{lastpage}';

footnote2 j=r 'Footnote2: -- ^{thispage} --';

                 

ods proclabel "Ms. Crabapple's Class";

          

title 'Class Health Information';

data _null_;

  file print ods; /* Use default table template */

  set sashelp.class;

  put _ods_;

run;

          

ods proclabel "Teacher - Crabapple";

       

title 'Class Roster - Girls';

data _null_;

  file print ods=(variable=(name age));

  set sashelp.class (keep=name sex age);

  where sex='F';

  put _ods_;

run;

          

ods proclabel "Teacher - Crabapple";

title 'Class Roster - Boys';

data _null_;

  file print ods=(variable=(name age));

  set sashelp.class (keep=name sex age);

  where sex='M';

  put _ods_;

run;

             

ods _all_ close;

ods listing; /* Reopen listing */


data_step_contents_rtf.jpg

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1370 views
  • 0 likes
  • 3 in conversation