The SAS Output Delivery System and reporting techniques

Getting Page X of Y in Body of the RTF

Reply
Occasional Contributor
Posts: 5

Getting Page X of Y in Body of the RTF

Dear All,

I am having an issue while generating an RTF output using ODS and Proc Report.

Usually, the titles and footnotes go to Headers and Footers when we generate an RTF output using proc report and ODS and we can also assign the page numbers (Page X of Y) by using the RTF tags, I am fine getting them.

But when I want to get those titles and footnotes in to the body of the output, I was able to get the titles and footnotes by using option BODYTITLE, in ODS RTF statement, but was unsuccessful in getting Page X of Y in the body of the output.

There are different way you can get, you can just generate .lst file and then use some word macro to convert that to RTF file.

But is there any way to generate Page numbers (Page X of Y) in the body of the RTF and not in the headers/footers.

Thanks & Regards,
Ranganath.

SAS Super FREQ
Posts: 8,641

Getting Page X of Y in Body of the RTF

Hi:

  The Page X of Y ODS ESCAPECHAR functions do not work with the original ODS RTF, as outlined in this Tech Support note: http://support.sas.com/kb/15/727.html

  However, if you switch to the TAGSETS.RTF destination (using SAS 9.1 or higher), you should be able to see page numbers in the body of the document. As these notes point out, you may only see the numbers in Print Preview mode or have to switch view modes to see the page numbers, but running the code in the note, I was able to get Page X of Y numbers in the body of the TAGSETS.RTF results file.

http://support.sas.com/kb/39/812.html and http://support.sas.com/kb/3/466.html .

cynthia

Occasional Contributor
Posts: 5

Getting Page X of Y in Body of the RTF

Hi Cynthia,

Thanks for the reply...

I agree with you that we can use ODS TAGSETS.RTF but we need to see that in print preview and then  the page X of Y are being displayed. But is there way by using Tagsets and permanently print the page X of Y in viewable way when we open the document.

Also, I have a question if we use TAGSETS.RTF, can we still use the style created by ODS TEMPLATE or do we need to specify the style in ODS TAGSETS itself.

Regards,

Ranganath.

SAS Super FREQ
Posts: 8,641

Re: Getting Page X of Y in Body of the RTF

Hi:

    Once SAS creates the RTF file, it has finished all the work that it can do -- SAS does not control your word processor software. How the RTF file is displayed and rendered by a word processor, in this case, Microsoft Word, is entirely up to Microsoft. SAS and ODS have inserted the correct RTF control strings into the output file. That is the reason that the Tech Support note says "There is not a way to force the page values to populate when viewing output from a screen." In earlier versions of Microsoft Word (2000, 2003), when you used the Page X of Y ESCAPECHAR functions, Microsoft Word would display the page information directly in the first view of the output, and did not make you go into Print Preview. However, by the time Office 2010 rolled around, this behavior changed.

  For example, in Word 2010, if I go into Word and create a new document (not using SAS at all) and I type something into my document. I must manually select Insert --> Header in order to put page numbers into the Word doc. If I am in any of these viewing modes: Draft, Outline, Web Layout or Full Screen Reading, I do not see any page numbers. I only see page numbers when I am in Print Layout or Print Preview mode. Therefore, it seems to me that this treatment of page numbers is how Word is designed to work, whether the file is typed into Word or is an RTF file. I think it is unlikely that Word can be changed to behave differently.

  If your destination supports style templates, then the STYLE= option will work whether you use ODS RTF, ODS TAGSETS.RTF, ODS LaTeX, ODS HTML, ODS MSOFFICE2K or ... Some of the destinations that do not use style template information are the LISTING destination, the CSV destinations and the CHTML and PHTML destinations.

  This is perfectly OK to do:

ODS TAGSETS.RTF file='someresults.rtf' style=journal;

...more code...

ODS TAGSETS.RTF CLOSE:

cynthia

Occasional Contributor
Posts: 5

Re: Getting Page X of Y in Body of the RTF

Hi Cynthia,

Thank you for detailed explaination.

I will work the things that you have specified and will get back to you... If I get in to any trouble.

Thanks & Regards,
Ranganath.

Occasional Contributor
Posts: 5

Getting Page X of Y in Body of the RTF

Hi Cynthia,

The output was generated with page of X of Y. But unfortunately if you see the output generated by the program: http://support.sas.com/kb/39/812.html. (executed by version 9.2). For the first page it is getting Page 1 of 2 for the rest of the pages there repeated as Page 2 of 2. But there are total of 4 pages.

Any ideas on how to handle this.

Thank you very much for your help.

Regards,
Ranganath.

SAS Super FREQ
Posts: 8,641

Re: Getting Page X of Y in Body of the RTF

Hi,

I believe that issue is related to how/when Word resolves the pagination of the document. This Tech Support note http://support.sas.com/kb/3/466.html outlined that the same or similar thing used to happen in Office 2000 and Office 2003 and the fix was to switch viewing mode. When I ran the example, I had to go to View --> Draft or View-->Web Layout and then switch to Print Preview and then the page numbers appeared correctly for me on all the pages. It was as though I needed to get Word to explicitly populate the values from the field codes by changing viewing modes AND going to Print Preview. But I did see the correct page numbers after I did the view change and then print preview switch. See attached screenshots.

cynthia

Attachment
Attachment
Occasional Contributor
Posts: 5

Re: Getting Page X of Y in Body of the RTF

Hi Cynthia,

Thank you for helping me through this problem and giving me detailed explaination.

But if we follow the same procedure "View --> Draft or View-->Web Layout and then switch to Print Preview" using the ODS RTF (without using TAGSETS.RTF) we can attain the same thing. And more over the ODS TAGSETS are not allowing the MS Word to recognize the RTF tags. I am sure the TAGSETS.RTF is used for having better control over the layout, but in cases where we need to use the RTF tags then I think the traditional ODS RTF (along with BODYTITLE and BODYTITLE_AUX) is holding it good.

For me, I am using MS-OFFICE 2007, I had to go one more extra step in order for the document to populate the page numbers that is print atleast 1 page Smiley Happy.

Thanks & Regards,
Ranganath.

Contributor
Posts: 31

Re: Getting Page X of Y in Body of the RTF

Hi Ranganath,

 

Can you send me TAGSets RTF with Proc Gplot code. I am facing same issue.

 

thanks for your help in advacne. 

Super User
Super User
Posts: 5,960

Re: Getting Page X of Y in Body of the RTF

At least with Office 2007 WORD will still display immediately in the file the field result values that you store using the \fldrstl tag.

For example here as simple one line RTF file that contains Page 1 of 1 done with commands. With SAS I have no idea how it could know what numbers to store in the file for a normal RTF output.  SAS would need to make a guess at how WORD was going to align the text onto the pages to figure out how many pages there are and what current page this instance of the PAGE field command is on.

{\rtf1

{Page }

{\field{\*\fldinst { PAGE }}{\fldrslt {1}}}

{ of }

{\field{\*\fldinst { NUMPAGES  }}{\fldrslt {1}}}

}

Post a Question
Discussion Stats
  • 9 replies
  • 1968 views
  • 0 likes
  • 4 in conversation