01-15-2015 02:10 PM
I make reports for a few people every month. My report has a few paragraphs and some tables and graphs. Paragraphs for all the reports are the same so I have them saved in a template however tables and graphs come from SAS output. Tables have number of each product ID that was purchased that month and other things so # of rows in table change. Number of columns stay the same. Graph is dependent on the results from the table. Right now, I create them as ODS with proc template and other option to make them pretty, however I would like to have the tables insert into word template directly (where I have my paragraphs saved). Is there a way to do that or am I stuck with copy/paste option?
01-15-2015 02:44 PM
@Reeza, Its a 10 page long document which will have several tables. I use ODS to save tables and then paste them into the template but do you think it would be easy bring the template in SAS and then put the tables into it?
01-15-2015 03:14 PM
So I've done this, but using Excel and then export the final file to PDF for distribution.
Here's the example. It's definitely a touch harder with Word and tables that change the number of rows.
A possible third option is manipulating the XML section of a .docx file to generate what you want. I haven't explored this option with Word, but have with Excel. It should be possible, but not sure if it's worth the work. I'd probably use @ballardw suggestion of embedded charts/tables linked.
01-15-2015 02:29 PM
I thought this approach from Dennis Fisher and Art Carpenter was interesting. Reading and Writing RTF docs as data. Seems like it could be an option.
01-15-2015 02:48 PM
Depending on complexity of formatting for the text it may be possible to use ods text and the procedures in a single program:
ods tagsets.rtf file="document name.rtf" options( Tables_off="User_Text" <other ods tagsetsrtf options>);
ods noproctitle; <likely you'll want ESCAPECHAR to modify style elements in the text >
ods text="First paragraph text";
proc freq data=dataset;
title "Some title";
<graphics proc goes here>
ods text = "More text";
ods text="Closing text";
ods tagsets.rtf close;
Another option is to write your output into specific named files and location and add links in your template document to those using Word (or other word processor )features.
Then update the links after the output, rename the document and then break the links so the content stays fixed.
Not my preferred approach but it is possible with care.