The SAS Output Delivery System and reporting techniques

How to have several RTF documents been packed into one document

Reply
Occasional Contributor
Posts: 10

How to have several RTF documents been packed into one document

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
Super User
Posts: 11,343

Re: How to have several RTF documents been packed into one document

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.
SAS Super FREQ
Posts: 8,868

Re: How to have several RTF documents been packed into one document

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
Occasional Contributor
Posts: 10

Re: How to have several RTF documents been packed into one document

Posted in reply to Cynthia_sas
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
SAS Super FREQ
Posts: 8,868

Re: How to have several RTF documents been packed into one document

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
Occasional Contributor
Posts: 10

Re: How to have several RTF documents been packed into one document

Posted in reply to Cynthia_sas
Dear Cynthia,

Got it and thinks for your help!

Best,
Aide
Contributor
Posts: 30

Re: How to have several RTF documents been packed into one document

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

Ask a Question
Discussion stats
  • 6 replies
  • 4318 views
  • 1 like
  • 4 in conversation