Lesson 46: ODS Document Destination
Video: ODS Document
Begin by loading some data and doing a regression example. We can use the manp data set which was used in earlier examples.
Observe that in the output window there are four tables created, which are also ods objects.
We are going to now use the "document" destination. The document needs a name. It is a SAS name similar to data set names. In fact, a two-level name can be used to store the document permanently. The document destination must be closed when you are finished with what you want to put in it.
Before running the code, you need to put the command "odsdocuments" in the command bar in the upper left corner of the SAS window. This opens a document window on the left side with the Results and Explorer. (It can also be done after running the program.) In this window there will be a tree which shows the objects in the document.
You have to navigate through the tree down to the "leaves" in the document which are the ods objects. Here you can right click and perform more tasks. Under "Open As" you can open them in various output destinations. You can also save them from the document viewer in these other formats.
These methods don't give us a chance to apply styles, though. There is another way this can be done. Just issue an ods command in your program that tells what kind of document you want to produce, such as:
odspdf file="c:\stat510\results.pdf" style=journal;
Now go to the document tree, right click on an object, and choose "replay." Then go back to the program window and close the ods destination.
This will create your document using the settings in the ods statement.
Now we'll do a few examples using proc document. You can specify the document name which shows up under the documents folder. One of the statments is "list" which will print some information about the path and names of objects. This may be needed to refer to the objects.
You can combine results from different runs, or reorder the results in a document by creating a new document. (You cannot reorder objects within an existing document, although you can delete objects.)
Right-click on documents and select "New Document." Give it a new name if you like. Select work or another directory in the list at the bottom. Now go to the tree for Manpresult and right click on an object, say "Parameter Estimates." Choose copy. Go to your new document folder and choose paste. I have found that the new object doesn't show up right away, but if you right click on the new document folder and select "Expand All" it will show up. You can copy and paste more objects from any of the documents you have in the document window to your new document. They will be entered in the order you listed, they are always added to the bottom of the document. You can then use the method above to replay the document into any destination you choose.
All of these things can also be done using proc document code. At present, I do not know how to do this correctly. It is something like the following, but the path is not right:
Copyright reserved by Dr. Dwight Galster, 2006. Please request permission for reprints (other than for personal use) from email@example.com . "SAS" is a registered trade name of SAS Institute, Cary North Carolina. All other trade names mentioned are the property of their respective owners. This document is a work in progress and comments are welcome. Please send an email if you find it useful or if your site links to it.