BookmarkSubscribeRSS Feed
StatsGuru
Calcite | Level 5

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

7 REPLIES 7
Reeza
Super User

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?

StatsGuru
Calcite | Level 5

@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?

Reeza
Super User

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.

Quentin
Super User

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

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Reeza
Super User

I think the varying number of rows would make that approach more difficult?

Tim_SAS
Barite | Level 11

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.

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1112 views
  • 1 like
  • 5 in conversation