SAS Enterprise Guide

Desktop productivity for business analysts and programmers
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3341 views
  • 1 like
  • 4 in conversation