BookmarkSubscribeRSS Feed
dtha2622
Calcite | Level 5

I'm relatively new to SAS, and recently discovered the ODS function. Currently, I've been copy and pasting a SAS output into different tables in a Word document, and was hoping to try and automate the process by loading up the template and having SAS output the data directly into a Word document into predefined tables.

 

I've done a bit of Googling have so far only found this paper. Admittedly I found it a bit hard to follow. Are there many other examples around of this being done?

 

 

3 REPLIES 3
Kurt_Bremser
Super User

The paper from 2003 uses DDE, which has since been deprecated by Microsoft.

You can use styles in ODS RTF and ODS WORD (at this time, WORD is still pre-production).

You cannot write to an exu'isting file, you always create a new one, so the whole document needs to be created by your code.

AlanC
Barite | Level 11

The best way to incorporate SAS and Microsoft Office files is to pull the data into Office vs pushing it from SAS. There are numerous libraries out there, some free/some not, that handle MS Office documents. SAS datasets are ODBC-compliant so you can write SAS then pull the data into a MS Office file. I use C# and the GemBox library but there are free alternatives in the C# and Python landscapes.

 

Personally, I have automated Word, Excel, PowerPoint, Project, and Visio with SAS data. I have not pushed from SAS at any of those client engagements. 

 

I don't have a paper on using Word specifically since Word is not used as often. However, see this code bit on GitHub to see Excel in action: savian-net/ExcelSasDemo (github.com). Chris Hemendinger also has lots of papers on SAS in .NET/PowerShell. If you need a demo for Word, I can probably put something together but the main idea is to pull vs push, Office pulling SAS data, not SAS pushing out Word.

 

Word is better at Word. Once SAS has the data in the form you need, it is just a table with rows/columns. 

https://github.com/savian-net
Bravez
Obsidian | Level 7

Our SAS hackathon project may help, it can inject values (not necessary to be a full table/dataset) into a Word paragraph, Word table, Word chart, including images. 

One-Click Report Automation - An automated and user friendly workflow for efficient, flexible, and e...

Ming Zou, MD PhD
SAS Hackathon 2022 - RepTik Analytics Solution, www.reptik.swiss
Easy report generation cross-platform. Create, format, and modify your tables & reports with the ease of Office Software and fill in with data from any source automatically via RepTik PDR technology.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 1843 views
  • 1 like
  • 4 in conversation