BookmarkSubscribeRSS Feed
Fluorite | Level 6
Dear all,

I use the ODS to generate some RTF documents, and now, I want to put them together into one document. What should I do? Can you help me?

Many thanks!

Super User
The easiest would probably be to put all of the output into a single ODS wrapper wihtout the individual RTF output.

ODS RTF File='long report.rtf';


ods rtf close;

or appropriate TAGSETS if using that RTF version.
The RTF specification has fairly strict requirements for what RTF control strings go at the top and bottom of an RTF document. Using 1 ODS RTF "sandwich" around all your report procedures is the only way to get ODS to put all your report output into 1 RTF file. (also applies to ODS PDF)

If you create one RTF file with ODS on Monday and then a second RTF file with ODS on Tuesday, you cannot use ODS to bring those 2 files together into 1 RTF file. You would need to combine the 2 files using a word processor (such as Microsoft Word) or you could "post-process" the 2 RTF files with a program to remove the control strings at the top of one file and the bottom of the other file to bring them together....and even then, you have to be really, really sure that you understand how the RTF control strings work so that you don't accidentally corrupt the RTF file.

So, by far, the easiest method is to make 1 ODS RTF sandwich with all your report code.

An alternative approach is to use ODS HTML or ODS MSOFFICE2K (another HTML-based destination, but Microsoft flavor of HTML) -- you CAN append a new file to the bottom of an existing ODS HTML file. Microsoft Word (assuming you have Office 97 or higher) can open the HTML and then you could resave the file as a .DOC or leave the file in HTML form and keep appending to it.

Fluorite | Level 6
Dear cynthia,

Thank you very much!

I know the easiest method that use 1 ODS RTF sandwich with all your report code.

What I need now is how to bring files, which is not created by the same program or files not created at the same time, together.

Could SAS read the RTFs into SAS, and then output them together again?

That is what I meant when I said you could "post-process" the differing RTF files.

To do that you would have to:
1) understand the RTF control strings that needed to be changed or removed;
2) write a DATA step program that would READ the multiple RTF files and change the RTF control string as needed, in each files and then would use FILE/PUT statementw to write the multiple RTF files back into a single ASCII text file.

This is not a trivial undertaking. You would not technically read the RTF files into SAS proprietary dataset format -- you would instead, use the power of the SAS programming language to read and alter multiple ASCII text files before writing them out again, as ASCII text files. Previous forum postings and a paper on this topic can be found here:㛃喼ᤣ

Fluorite | Level 6
Dear Cynthia,

Got it and thinks for your help!

Obsidian | Level 7

Hi Aide

Further to the link Cynthia gave ie ( I believe I have observed

a simple solution to this.


Similarly here:



Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 like
  • 4 in conversation