BookmarkSubscribeRSS Feed
Clara
Calcite | Level 5

I use ODS RTF to create tables.  After that, I must include other rtf-tables (which were not produced in SAS) in rtf - document by hand.  Is that possible to automize this in SAS? And if so how?

Thanks

Mounira

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  The RTF specification is very strict about the opening and closing RTF control strings, including the lists or indices that control colors and fonts. Because of this, what you want to do is not a trivial task. Even if you could combine the files, one created with SAS and the other created by some other method, it would be very easy to get two conflicting sets of opening control strings strings and consequently cause the output tables to either not look right (the best case) or create a corrupted and unopenable RTF file (the worst case). An RTF file can only have 1 set of opening controls and one set of closing controls and you would have to know the RTF specfication very, very well to be able to automate the process and write a program to strip out the table and only the table from the non-SAS RTF file -- but that would probably mean that even if you could strip out the table, you would probably lose any special formatting that the table had.

 

  One alternative that might work would be to write a VBA or Word macro to open the SAS RTF output into Word, and then open the other RTF document and use VBA commands to cut and paste from one file into the other. I'd then recommend resaving the whole (new and combined) file as a Word.doc file.

cynthia

art297
Opal | Level 21

While Cynthia is probably right (as she usually is), I did come across the following Pharmasug paper that might provide you with a method for accomplishing the task: http://www.lexjansen.com/pharmasug/2010/po/po05.pdf

ballardw
Super User

Once upon a time I had a loosely related project that involved placing lots of external data into a Word document. You don't mention if you are using Word or how the external tables are generated so this may not apply.

One approach could be to use links in Word. If each of the SAS tables you need are exported to a separate file whose name does not change then a Word document could be made with instructions to LINK each one. If the external RTF tables have a similar behavior then linking to those as well as the SAS output may accomplish the task.

Since the locations of the source documents and file names will in effect be hard coded in the links my approach with this method was to export / create all of the supporting documents to someplace that made sense. Then when all of the data was ready copy it into a specific source document folder that the Word document would look for them. Open the Word document, refresh all of the links, SAVE AS A NEW DOCUMENT then break all of the links and save again.

Somewhat cumbersome but in lieu of manually pasting 40 odd charts and 120 paragraphs of conditional text for 50+ reports it made lots of sense.

Duong
Obsidian | Level 7

Hi Clara

If you are looking to stack RTF files then here are another two papers about this.

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

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

It is a lot more simpler than to think.

Regards

Duong

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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