DATA Step, Macro, Functions and more

Advance ODS or something else

Reply
New Contributor
Posts: 2

Advance ODS or something else

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

Super User
Posts: 17,829

Re: Advance ODS or something else

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?

New Contributor
Posts: 2

Re: Advance ODS or something else

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

Super User
Posts: 17,829

Re: Advance ODS or something else

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.

PROC Star
Posts: 1,231

Re: Advance ODS or something else

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

Super User
Posts: 17,829

Re: Advance ODS or something else

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

Super Contributor
Posts: 394

Re: Advance ODS or something else

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.

Super User
Posts: 10,500

Re: Advance ODS or something else

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.

Ask a Question
Discussion stats
  • 7 replies
  • 332 views
  • 1 like
  • 5 in conversation