2. Presentation Overview
Introduction
Background
A Mixture of Examples, Syntax, and
Output
Quick GUI Example
References
3. Introduction
Prior to SAS v.9, necessary to rerun
ODS code manually if the output
destination changed (e.g. RTF to PDF).
Now, ODS output can be stored as
“documents” which can be opened
across multiple output destinations.
4. What is a SAS document?
A unique ODS destination which stores both
the data components (i.e. tables, reports,
text) and the style components (“rules” for
output appearance)
Both components form an Output Object
(what we see generated once we open the
output destination)
The Output Object is compiled just prior to
SAS writing to the ODS destination
5. Content of a SAS Document
What is included?
Output object
Context
Hierarchy
What is not included?
Proc options
System options
ODS options
Graph options
GRSEGs (Graph segments)
External graph title customizations
6. Syntax for Creating an ODS
DOCUMENT
ODS DOCUMENT NAME=<libref.>member-name (access-option(s));
…procedure code…
ODS DOCUMENT CLOSE;
17. Summary
The ODS DOCUMENT destination is a versatile output
destination which allows the programmer to create
custom reports based on manipulating Output
Objects.
Output Objects have two parts: a data component
and a style component.
Modify Output Objects with either PROC DOCUMENT
or odsdocument GUI.
Replay Output Objects across multiple ODS
Destinations with the REPLAY option of PROC
DOCUMENT.
19. Sources and
Acknowledgements
SAS Online Documentation
http://support.sas.com/onlinedoc/913/docMainpage.jsp
Keyword: PROC DOCUMENT
SAS Global Forum 2007
SAS 9 ODS DOCUMENT and PROC DOCUMENT Tip Sheet
Karp, Andrew H. A Peek at PROC DOCUMENT. SAS Global
Forum 2007 Tutorials; Paper 224-2007
I would like to thank both my Coworkers and Supervisor who
took the time out of their busy work schedules to proof this
presentation for accuracy and readability.
Editor's Notes
Have it your way! This presentation does not endorse nor support any particular eatery in any way, shape, or form.
This presentation will cover the background required and necessary syntax to successfully utilize the Document ODS Destination. We will also show an example of where knowledge of the Document ODS Destination would save the programmer time in creating a custom report for a study team and/or Principle Investigator (PI).
First a brief introduction to one use of the ODS Document Destination. Prior to SAS v.9, people were required to rerun ODS code manually if the output destination changed (i.e. RTF to PDF) or delete procedural output containing numerous tables and graphs by hand if only certain tables or graphs were requested by the PI and/or Stat Team. Now, people can store ODS output as “documents” which can be opened across multiple output destinations and allows the programmer to control the output generated by various procedures.
A central concept for understanding both the ODS DOCUMENT and PROC DOCUMENT statements is familiarity with a SAS ‘Document’. Similar to a Word or RTF document, a SAS document is a joining together of both the content (data component) and display (style component) of an output object (finished product).
A SAS Document contains the following: the output object (tables, graphs, notes, and equations), the context (a set of style attributes that are attached to the output object), and the hierarchy (several “background” descriptions, one of which is the output object’s order in the ODS destination). A SAS Document however does not maintain global SAS program options associated with graphics, ODS, and the system.
Similar to the syntax for other ODS destinations such as PDF and RTF , DOCUMENT is another recognized ODS destination in SAS v9. Following ODS DOCUMENT is the name of the specific document. If no library is specified, SAS will default to the working library. The library reference must be a valid SAS library member and the name of the document must follow SAS naming conventions. In addition, one can specify the access-options with one of the following keywords enclosed in parenthesis: write: creates a new document and overwrites a document with the same name. -or- update: creates a new document and appends a document with the same name. Proceed writing the procedure code you wish to output and close out the ODS destination with an ODS DOCUMENT CLOSE .
For the example, we will use a portion of a SAS analysis file to hypothetically create a report for the study team. The study team requests a report on the results of a logistic regression of experiencing a “night sweat” by several demographics. The logistic regression model is to be fitted by a backwards elimination process, with the final model keeping only response variables which are at a significance level of 0.10 or less. In addition, the study team would like a Spearman Correlation of the most recent hemoglobin levels with the Brief Fatigue Inventory Overall Score and Fatigue Subscale Score. Finally, the study team would like to see correlation plots of the most recent hemoglobin levels with both scores. The ODS Document Destination will allow us to capture the specific output in the format requested through PROC DOCUMENT.
The following example will use the displayed statements from PROC DOCUMENT: The DELETE statement will remove entries from a specified path or paths, LIST will list the content of the specified path, MOVE TO will move entries from one directory to another directory, OBPAGE will create or delete a page break for an output object, REPLAY will replay one or more entries to the specified ODS destination(s), and SETLABEL will assign a label to the current directory.
The code shown in the above slide utilizes the LIST statement of PROC DOCUMENT to list out the levels of the directory work.myreport . The option levels=all displays all levels of the directory.
This is the first part of the generated output. As we can see, the listing is of the DOCUMENT Myreport … all the levels of the output objects are shown… On the far left we have each level numbered beginning with 1… The next column has each of the pathnames listed with each segment in the path, separated by backslashes (\\) consists of a name (Logistic) as well as a sequence number (#1). Sequence numbers are used to ensure that each directory and object is uniquely addressable… On the far right we have the type of each output object ( Dir , Table , Note , or Tree ).
There are 111 objects in the Logistic Regression Model with Backward Elimination alone! Time to clean up the output such that we only present the Correlation Plots, Model Building Summary and the Simple Statistics / Spearman Correlation Matrix to the study team. We need to use the remaining PROC DOCUMENT options in order to accomplish this task.
To modify the ODS Document to display only Correlation Plots, Model Building Summary and the Simple Statistics / Spearman Correlation Matrix we will use the displayed code. MOVE TO statements will move each output object to the current directory ( \\work.Myreport \\ ) as indicated by the caret (^) symbol. SETLABEL statements will label the specified paths to what we specify in the quotations. OBPAGE statements will allow us to create page breaks in the resulting output. The AFTER option will create the breaks after the object path. DELETE statements will control the output and limit our resulting output to the two Correlation Plots, Model Building Summary for the Logistic Regression, and Summary Statistics/Spearman Correlation Matrix. LIST will list out the output objects and allow us to verify changes.
As we can see from the resulting output, the list of output objects generated is much reduced. Now we have the tables and graphs requested by the study team, and nothing else.
In addition to modifying procedural output for customized reports, we can replay the document in various ODS Destinations by merely using the REPLAY option of PROC DOCUMENT. The code presented on this slide allows us to replay the document myreport as a PDF. By changing the ODS Destination, we can replay the same report across multiple formats similar to PROC GREPLAY for SAS Graph.
Go through the resulting PDF Document. Note the reduced output from the logistic procedure and the customized table headings on the sidebar.
For SAS Interactive Users, much of what was covered in this presentation could be reproduced in a GUI interface by typing odsdocument in the Command Line. The resulting pop-up window looks and acts much like the Results Window, but more customizable.
None.
None.
Further information on ODS DOCUMENT and PROC DOCUMENT can be found in the displayed resources. I would like to thank the Coworkers and Supervisors who took the time out of their busy work schedules to proof this presentation for accuracy and readability.