BookmarkSubscribeRSS Feed
tacit
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!

Aide
6 REPLIES 6
ballardw
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.
Cynthia_sas
SAS Super FREQ
Hi:
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.
http://support.sas.com/kb/24/034.html
http://support.sas.com/kb/35/375.html (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.
http://support.sas.com/kb/23/660.html

cynthia
tacit
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?

Best,
Aide
Cynthia_sas
SAS Super FREQ
Hi,
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;
then
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:
http://support.sas.com/forums/thread.jspa?messageID=14019㛃
http://support.sas.com/forums/thread.jspa?messageID=21948喼
http://support.sas.com/forums/thread.jspa?messageID=6435ᤣ
http://www.lexjansen.com/pharmasug/2010/po/po05.pdf

cynthia
tacit
Fluorite | Level 6
Dear Cynthia,

Got it and thinks for your help!

Best,
Aide
Duong
Obsidian | Level 7

Hi Aide

Further to the link Cynthia gave ie (http://www.lexjansen.com/pharmasug/2010/po/po05.pdf) I believe I have observed

a simple solution to this.

See http://www.lexjansen.com/phuse/2011/pp/PP04.pdf

Similarly here: http://www.lexjansen.com/pharmasug/2012/AD/PharmaSUG-2012-AD12.pdf

Regards

Duong

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
  • 7810 views
  • 1 like
  • 4 in conversation