BookmarkSubscribeRSS Feed
Ranganath
Calcite | Level 5

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.

9 REPLIES 9
Cynthia_sas
SAS Super FREQ

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

Ranganath
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ

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

Ranganath
Calcite | Level 5

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.

Ranganath
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ

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


after_switch_right.jpgbefore_wrong.jpg
Ranganath
Calcite | Level 5

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.

vandhan
Fluorite | Level 6

Hi Ranganath,

 

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

 

thanks for your help in advacne. 

Tom
Super User Tom
Super User

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}}}

}

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
  • 9 replies
  • 6058 views
  • 0 likes
  • 4 in conversation