Hello everyone,
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?
Thanks,
AG
How about an ODS RTF Destination?
Or do you have SAS Add-in for MS Office
Is there a way to bring the paragraph into the SAS process?
@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?
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.
http://www.health.alberta.ca/documents/PHC-Profile-Banff.pdf
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.
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.
http://www.pharmasug.org/proceedings/2012/TF/PharmaSUG-2012-TF16.pdf
I think the varying number of rows would make that approach more difficult?
If you're running 9.4 and you're creating ODS RTF output, then you could use PROC ODSTEXT to write the paragraphs into the RTF along with your tables and graphs.
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;
tables var;
title "Some title";
run;
<graphics proc goes here>
ods text = "More text";
<other procedures>
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.