BookmarkSubscribeRSS Feed
Sudhakar_A
Calcite | Level 5
Hi,

I have RTF output created by SAS ODS, Is there any way to append all the RTF outputs and Create a Table Of Content for this appended document.

Thanks
Sudhakar
9 REPLIES 9
Cynthia_sas
SAS Super FREQ
Hi:
If you put all your steps into 1 ODS RTF "sandwich", then all the tables would be together in one RTF document -- with 1 table of contents. Something along these lines:

[pre]
ods rtf file='somefile.rtf' contents=yes toc_data;
*** proc or data step 1;

*** proc or data step 2;

*** proc or data step 3;
run;
ods rtf close;
[/pre]

As explained in this Tech Support note
http://support.sas.com/kb/24/034.html
you cannot append RTF files together using SAS.

The only ways to assemble multiple RTF files together are:
1) put all your SAS code within one ODS RTF "sandwich" -- so that the parts/sections of your document are built by SAS from multiple procedures.
2) assemble your multiple RTF files in Microsoft Word or some other Word processor (possibly using VBScript or a Word macro)
3) post-process the RTF files with a program to selectively remove the RTF control characters that define either the beginning or end of a file.

There have been other forum postings on this topic:
http://support.sas.com/forums/thread.jspa?messageID=5513ᖉ
http://support.sas.com/forums/thread.jspa?messageID=6434ᤢ
http://support.sas.com/forums/thread.jspa?messageID=14026㛊

cynthia
Sudhakar_A
Calcite | Level 5
Thank you very much. I will explain my situation

1. Output1.rtf generated by User1
2. Output2.rtf generated by user2

So One output is independent of each other so after all the outputs are generated we have to append these outputs and also to create a TOC

Thanks in advance
Cynthia_sas
SAS Super FREQ
Hi:
So, the #1 workaround, as explained above will not work for you. That leaves only #2 (do something in Word to assemble the files and build the TOC) or #3 post-process the RTF file with a program.

Your only other alternative (depending on what procedures you are using for each report table) might be to create an ODS DOCUMENT store and then assemble the final document using ODS DOCUMENT and PROC DOCUMENT statements. But that means you would create the ODS DOCUMENT store -instead of- the RTF files from user1 and user2. Then your final RTF file would be built from these document objects, not from existing RTF files. For an overview of ODS DOCUMENT capabilities, refer to these papers or the ODS DOCUMENT documentation:
http://support.sas.com/resources/papers/sgf09/318-2009.pdf
http://www.lexjansen.com/wuss/2003/DataPresentation/i-peek_at_proc_document.pdf

cynthia
Sudhakar_A
Calcite | Level 5
Hi,

It was a good idea to make this happen, i read this document and when i was trying to use this i got the warning "WARNING: PROC REPORT does not support the ODS Document in this release."

Thanks for the help.

Sudhakar
ballardw
Super User
I think the way to generate your TOC from separately created RTF would be by using the RTF field codes using RTF TEXT.

Place this code in document portion and position that you want the TOC to appear:
ODS RTF TEXT="{\field{\*\fldinst {\\TOC \\f \\h} } }";
to insert the field code for a table of contents that will also create hyperlinks to the entries.

Before each item in your report insert at table of contents entry code using:
ods rtf text= " {\tc \tcl }";

The is used to create indent levels when desired, use 2 or greater such as \tcl2. If you just have \tc then all items will be at the main level of the TOC.

Style elements can be used to modify the text by placing the style descriptors before the {. The text will also appear in the body of your document using the styles but the TOC settings for the document will control appearance in the TOC.

After all of the document sections are merged, I assume using Word, then find the TOC field and do the Update all entries to display the table. I found it a bit difficult to find the field as there isn't anything visible but if you place it on an empty page near the start of the document you should be okay.

Note that this does not use any of the SAS procedure TOC entry behaviors so individual tables to not get entries, just what you supply.

DO NOT use the highlight all and menu item to insert a table of contents as you will create a separate TOC entry.

I hope this helps.
Sudhakar_A
Calcite | Level 5
Hi,

Thank you vey much its seems this idea will work i will try this way.

Thank once again for all.

sudhakar
ballardw
Super User
I forgot to mention that you will need to use a style that has PROTECTSPECIALCHARACTERS=OFF set.

I believe this is mentioned in http://support.sas.com/resources/papers/sgf09/318-2009.pdf
Cynthia_sas
SAS Super FREQ
Hi:
I don't remember PROTECTSPECIALCHARS in that paper! But look on page 8 of this paper:
http://www.nesug.org/proceedings/nesug06/io/io13.pdf

...it talks about all the various methods of creating and customizing a Table of Contents specifically for the RTF destination.

cynthia
TriciaAanderud
Lapis Lazuli | Level 10
I kept getting an error that Word could not understand my formatting. I realized that it is "\TCL" and not "TC1" after nearly pulling my hair out.

Tricia Aanderud

Twitter: @taanderud - Follow me!

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
  • 2620 views
  • 0 likes
  • 4 in conversation