|
|||
|
We are writing a number of documents. The problem here lies in the
maintainance of said documents so that the .rtf output of a SAS table can be linked to the document so that the document stays current. I can easily do this in LaTeX. However, we have not done it in Word. Has anyone solved this problem? A solution involves 1) a simple output of a table to a file 2) an inclusion of that table into a word document 3) opening the word document sucks in the updated tables so that the document stays current. additionally, it would be nice if we could update INCIDENTAL comments in the text |
|
|
||||
|
||||
|
|
|
|||
|
Paul Thompson wrote:
> We are writing a number of documents. The problem here lies in the > maintainance of said documents so that the .rtf output of a SAS table > can be linked to the document so that the document stays current. > > I can easily do this in LaTeX. However, we have not done it in Word. > > Has anyone solved this problem? A solution involves > > 1) a simple output of a table to a file > 2) an inclusion of that table into a word document > 3) opening the word document sucks in the updated tables so that the > document stays current. > > additionally, it would be nice if we could update INCIDENTAL comments > in the text Suppose you have some report document containing narrative and tables, such that the table contents are to be dynamic. Here is an example to get the idea rolling Step 1. Create some output. ods csv file='c:\temp\class.csv'; proc report data=sashelp.class nowd; run; ods csv close; Step 2. Create a new Word document - Activate database toolbar - Select Insert Database - Click Get Data - Enter c:\temp\class.csv - Open - Click Table AutoFormat - Select Colorful 2 - OK - Click Insert Data - Activate Insert data as field - OK Your document now shows a table populated with data from an earlier SAS run Save the file as CLASS.DOC Step 3. Update the doc external data by submitting a SAS program again ods csv file='c:\temp\class.csv'; proc report data=sashelp.class nowd; proc report data=sashelp.class nowd noheader ; run; ods csv close; Step 4. Update the table in the doc - Click in a cell in the table - Press F9 You should get the idea. One shortcut to updated all fields in a doc - Ctrl A, F9 I don't know if there is a secure way to force all fields to always update when the document is opened. That behaviour might be more in the vein of inserted objects. Something like Insert/Object, CreateFromFile, Activate Link to file, Filename: c:\temp\class.csv Also, perhaps the new SAS excel table plugin also works in word. -- Richard A. DeVenezia http://www.devenezia.com/ |
|
|||
|
p.s.
If the word document (with the database inserted as a field) is saved as an rtf, the field is still there when the rtf is opened. This means there is a possibility the Proc TEMPLATE could create a TAGSET that renders these data fetching types of documents. A thorough knowledge of rtf syntax would be useful. The tagset would have to render stuff like this into the output stream: {\field{\*\fldinst { DATABASE \\d "C:\\\\temp\\\\class.csv" \\c "DSN=Rich;DBQ=C:\\\\temp;DefaultDir=C:\\\\TEMP;Dri verId=27;FIL=text;MaxBuffe rSize=2048;PageTimeout=5;" \\s "SELECT * FROM class.csv" \\l "9" \\b "191" \\h }} p.p.s. Word97 will not let you use a URL as a database source, although using a system dsn hooked up to some sort of http: enabled odbc driver is not out of the question. -- Richard |
|
|||
|
You mention that you can do this easily in LaTeX.
Have you considered writing SAS code that outputs marked-up LaTex?? (could be slightly painful). Then let the LaTeX engine convert to rtf... just a thought (untested). regards, Avram On Oct 25, 2004, at 7:44 PM, Richard A. DeVenezia wrote: > Paul Thompson wrote: >> We are writing a number of documents. The problem here lies in the >> maintainance of said documents so that the .rtf output of a SAS table >> can be linked to the document so that the document stays current. >> >> I can easily do this in LaTeX. However, we have not done it in Word. >> >> Has anyone solved this problem? A solution involves >> >> 1) a simple output of a table to a file >> 2) an inclusion of that table into a word document >> 3) opening the word document sucks in the updated tables so that the >> document stays current. >> >> additionally, it would be nice if we could update INCIDENTAL comments >> in the text > > Suppose you have some report document containing narrative and tables, > such > that the table contents are to be dynamic. > > Here is an example to get the idea rolling > > Step 1. Create some output. > ods csv file='c:\temp\class.csv'; > proc report data=sashelp.class nowd; > run; > ods csv close; > > Step 2. Create a new Word document > - Activate database toolbar > - Select Insert Database > - Click Get Data > - Enter c:\temp\class.csv > - Open > - Click Table AutoFormat > - Select Colorful 2 > - OK > - Click Insert Data > - Activate Insert data as field > - OK > Your document now shows a table populated with data from an earlier > SAS run > Save the file as CLASS.DOC > > Step 3. Update the doc external data by submitting a SAS program again > ods csv file='c:\temp\class.csv'; > proc report data=sashelp.class nowd; > proc report data=sashelp.class nowd noheader ; > run; > ods csv close; > > Step 4. Update the table in the doc > - Click in a cell in the table > - Press F9 > > You should get the idea. > One shortcut to updated all fields in a doc - Ctrl A, F9 > > I don't know if there is a secure way to force all fields to always > update > when the document is opened. That behaviour might be more in the vein > of > inserted objects. Something like Insert/Object, CreateFromFile, > Activate > Link to file, Filename: c:\temp\class.csv > > Also, perhaps the new SAS excel table plugin also works in word. > > -- > Richard A. DeVenezia > http://www.devenezia.com/ > |
|
|||
|
Avram Aelony wrote:
> You mention that you can do this easily in LaTeX. > Have you considered writing SAS code that outputs marked-up LaTex?? > (could be slightly painful). > Then let the LaTeX engine convert to rtf... > > just a thought (untested). > > regards, > > Avram I wrote that macro 10 years ago. I can do anything I want with LaTeX. However, no one else in my group is willing to go that route. And I do not want to be a table making slave. If you were interested in my LaTeX table making SAS macro, let me know. Works like a charm. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|