DATA Step, Macro, Functions and more

Link to SAS tables from a Word report

Reply
Respected Advisor
Posts: 4,641

Link to SAS tables from a Word report

Hi fellow Forum members,

I would like to link to SAS output tables from MS-Word documents. I tried creating the tables into a RTF document with anchors using ODS and then referring to these anchors from my Word report. That didn't work. I can create a hyperlink to the table in the RTF document but I can't make the table appear in my report. Can it be done?

PG
PROC Star
Posts: 7,356

Re: Link to SAS tables from a Word report

: from word, if you click on insert and then on the icon shown below, followed by "Text from File", you can insert rtf and html files into word documents:

word_menu.jpg

Respected Advisor
Posts: 4,641

Re: Link to SAS tables from a Word report

Thanks Art for the detailled instructions. I tried that and it didn't include anything into my Word document (it didn't signal any error). Does it work for you? I'm using SAS 9.3 and Word 2007.

- PG

PG
PROC Star
Posts: 7,356

Re: Link to SAS tables from a Word report

Yes it did work for me.  I'm using Word 2010.  However, it wouldn't update the document when the html or rtf document changed.

If you can attach one of the files, I'll see if it works on that particular file.

PROC Star
Posts: 7,356

Re: Link to SAS tables from a Word report

: Try following the instructions shown in the following link: Automatically Updating Text in Many Documents

This actually links the files with the new document so that the document is updated when anything in the link changes.  The instructions, basically, are just to:

1. Create a document containing the text you want to link to

2. Copy the text you would like to insert in your other documents

3. Open the document where you would like to insert the text

4. Place the cursor where you would like the text to appear

5. From the Edit menu, select Paste Special

6. From the Paste Special dialog box, select Paste Link

I tested it, at least in Word2010, by inserting an HTML document into the new document.  I presume it should work with rtf as well.

Respected Advisor
Posts: 4,641

Re: Link to SAS tables from a Word report

Hi Art,

Thanks for your time and ideas. Like so many half baked features in MS-Office, this one almost looks like it works. When I paste a link to my table, Word inserts a new bookmark in the RTF file. It call it OLE_LINK1. It doesn't use the bookmark that was inserted by SAS for the same table. If I edit the RTF file with Word, the edits will be carried over to my report. But this also means that when I update the RTF file by running my SAS program again, the inserted link (OLE_LINK1) is lost and the link is broken.

PG

PG
Super Contributor
Posts: 1,636

Re: Link to SAS tables from a Word report

Hi PG,

Do you think mail merge would work?

Respected Advisor
Posts: 4,641

Re: Link to SAS tables from a Word report

I'm not familiar with mail merge. Can whole tables be inserted with it? - PG

PG
Super Contributor
Posts: 1,636

Re: Link to SAS tables from a Word report

Hi PG,

I tried. I can only insert a row from a table not the whole table. Sorry.

Valued Guide
Posts: 2,174

Re: Link to SAS tables from a Word report

could a hyperlink in the word doc open a SAS table in the SAS Universal Viewer, and would that be of adequate quality of presentation?

PROC Star
Posts: 7,356

Re: Link to SAS tables from a Word report

: Methinks that is one for SAS to take care of, namely offering to maintain links when a file is replaced.

Super User
Posts: 17,750

Re: Link to SAS tables from a Word report

Hi PG,

Can you explain a bit more of what you're trying to do?

What do you mean by a SAS Table? Is it in another word document and what kind of link are you looking for.

Respected Advisor
Posts: 4,641

Re: Link to SAS tables from a Word report

A SAS table is the formatted version of an ODS dataset. I guessed the RTF version of a table would be the most compatible with Word.

I am looking for an updatable (dynamic?) link. If I redid the analysis in SAS, I would like to see the updated version in my Word report.

PG

PG
Super User
Posts: 17,750

Re: Link to SAS tables from a Word report

Is that still a SAS dataset, ie sas7bdat file?

You can embed an excel table into a word document. And if you update the source excel table via SAS either through a simple proc export, DDE or other manner it should update in Word as well.

Respected Advisor
Posts: 4,641

Re: Link to SAS tables from a Word report

Thanks for the suggestion Reeza, but a raw data table is not what I need to include in my report.

It's the formatted version of a SAS table that I want to link to, something like :

Capture Report.PNG

It would be part of a RTF file and pointed to within the file by an anchor name. I can bring such a table from the RTF output to my report with cut and paste but I would like to make the process automatic.

PG
Ask a Question
Discussion stats
  • 19 replies
  • 2694 views
  • 6 likes
  • 8 in conversation