I was wondering if there was a way to add a table or graph to an existing text document. For example, if we have a Word document containing specific text, I would like to add table output from PROC REPORT or a graph to the text, and write the result out to a single RTF document.
If this is possible, are there ways to control where the insertion of the table or graph occurs?
The info about the RTF file also applies to PDF. Basically, both RTF and PDF have a very stringent (not flexible) syntax for the way they want the file open and file close to be specified.
You might consider writing a little VB script for Word that opens the first RTF file, brings in or inserts the second RTF file and then resaves the "new" document over the first file name. There might be 3rd party software that allows you append 2 RTF files together -- I'm betting they strip out the file close from the first file and the file open from the second file to make it work. I suppose you could also write a DATA step program to post process the 2 files and do the same thing, but the few times that I've messed with post-processing RTF, I've generated a corrupted RTF file too easily. RTF is hard to figure out and 1 wrong curly brace or \ and bam, you've corrupted the RTF file and Word won't open it.
Of course, one simple technique might be to save your original output objects (if possible) in an ODS Document store and then when you need to add information, you could replay the first document's output objects with the new output objects and make a new RTF file or write over the old name.
Another thing you could do is use ODS RTF TEXT= to insert big blocks of text around your table and/or graph. This is sort of doing the reverse that you asked about -- you would be taking the text from the first document and would add it to the new document.
An example of using ODS RTF TEXT= is shown below.
length bigtext $2000 line $100;
** can not use end= with datalines, so use lineno var;
** to create macro variable at end of poem.;
if lineno = 8 then do;
1,"Twas brillig and the slithy toves,"
2,"Did gyre and gimble in the wabe."
3,"All mimsy were the borogroves."
4,"And the mome raths outgrabe."
5,"Beware the Jabberwock, my son!"
6,"The jaws that bite, the claws that snatch."
7,"Beware the Jubjub bird and shun"
8,"The frumious Bandersnatch!"
You can disappear the characters with the SHOW/HIDE button inside Word. Or, you can tell ODS RTF not to insert them at all. The ODS option is described in the Tech Support note and to use it, you would have this in your code:
ods rtf file='somefile.rtf' notoc_data;
... more code...
ods rtf close;
Thank you so much for the information! As always, you seem to have the answer!! I will test out the different options that you provided, and I will let you know if any of them work for what I need. I have a feeling that the TEXT= method might be sufficient for what I am trying to do.