Upload
jake-linden
View
217
Download
0
Embed Size (px)
Citation preview
Managing Your SAS Output with the Document Procedure
PhilaSUG MeetingMarch 15, 2011
Outline
• Review of Output Delivery System
• What is the ODS Document and what can it do for you?
• Quick-Start course
• Listing and Replaying Documents
• Additional Capabilities – quick overview only
• How to find out more
• Q&A
Scenario – Which one is my analysis for TODAY's meeting?
3/15/11 4
What can be stored in a Document?
SAS/Graph Graphics
ODS Statistical Graphics SAS Data Sets (small)
Text Notes
“As you can see from the previous output, the clustering is quite strong”
SAS Procedural Output
Using The Document Procedure is EASY• Save Output Now:ODS DOCUMENT
NAME=philasug.mystuff;<your sas code>
ODS DOCUMENT CLOSE;
• Replay Output Laterproc document
name=philasug.mystuff; replay; run; quit;
3/15/11
Two Approaches to Learning PROC Document• “Google Approach”
• Use no folders, and use the WHERE statement to create searches to specify which output is replayed
• Good for beginners, so you can focus on ODS rather than file management
• Approach used in this presentation
• “Yahoo Approach”• Use lots of folders, set them up before you even start adding output to the
document
• Direct output to the propre folder with the ODS Document command
• Combination• Most people will use a combination of these!
3/15/11 7
What sort of Output does the Document Store?
To replay output, you need all three. The Document saves the first two, and some formats.
Template
Informatio
nODS Table or
Graph
Formats
Titles & Footnotes
Object Notes
Context
3/15/11 8
How the Output Delivery System Works Without The
ODS Document
3/15/11 9
With the ODS Document
3/15/11 10
Organization of the ODS Document Like a directory Output from Each SAS
Procedure has its own Each folder Named for its
procedure Can have more than one
folder with PROC REG output, for instance
Each output object and directory has a path-name, derived from ODS naming conventions
3/15/11 11
Talking to the Output Delivery System Every output has an ODS pathname
ods trace on;
proc univariate data=sashelp.class; by sex; var height age;run;
ods trace off;
3/15/11 12
Ods Stores data in the document based on the ODS Pathname
Output Added: (you can find this message in the Sas LOG)-------------Name: MomentsLabel: MomentsTemplate: base.univariate.MomentsPath: Univariate.ByGroup1.Height.Moments-------------
Terminology of the ODS part IIAll four of these terms, Name, Label, Template, and Path can be used to search the document,hence worth learning
Example ODS Trace output: Use it to teach you ODS names of output you commonly use.
3/15/11 13
The ODS Document Statement, Building a Document
ods document name=<docname><(access-mode)>
<DIR=(path specification) <LABEL=“label text”>
PROC ….
DATA Steps with ODS output
ODS Document Close;
ODS Document exclude/exclude statements;
ODS Include PARAMETERESTIMATES;Proc reg;...
3/15/11
Access Modes
READ (read-only) access
WRITE – not what it sounds!
- ERASES the ENTIRE document, then inserts the new data. Should be called Over-write mode.
Update – The default
Will continually append new output after old output
3/15/11
Quick Aside – deleting a Document
proc datasets lib=nesug mtype=itemstor; delete firstdoc;quit;
/* can also rename */
SAS ODS Documents are of type ITEMSTORE, which when abbreviated to eight letters is ITEMSTOR. The only place you need to know this fact is for this delete.
For most document management tasks, use PROC DOCUMENT, NOT PROC DATASETS.
3/15/11 16
List contents of document (LIST) commad Replay documents (REPLAY) command Create Labels for each output object Create, Manage, and Delete Folders Create Shortcuts to subfolders, Notes, Titles all
without re-running the original analysis Make changes to graphs (SAS 9.3)
Jobs of the Document Procedure
3/15/11 17
Invoking The Document Procedure
PROC DOCUMENT Name=<docname><(access mode)> <Label=>;
3/15/11 18
LIST Command PROC DOCUMENT Name=<docname>
<(access mode)> <DIR=> <Label=>;
LIST paths / options ;
Run ;
Quit ;
Levels= n | ALLDetailsBYGroups
Most Useful Options
MUST HAVE!
3/15/11 19
Output from LIST; with no options
One directory (pathname) for each PROC called
Levels=1 is the default
Automatically generated Sequence Numbersensure all objects have unique names
Name of base directory (default is root directory)
3/15/11 20
LIST / DETAILS LEVELS=ALL;
3/15/11 21
What Happens when you Replay?
To replay output, you need both. The power of PROC Document comes from the ability to change information in the Pink Square to modify appearance while leaving blue square alone.
Style!
Fonts
Highlighting
Fill Colors
Actual Template
Stored in Document
TemplateInformation
ODS Table or Graph Formats
Titles & Footnotes
Object Notes
Context
TemplateInformationTemplateInformation
ODS Table or GraphODS Table or Graph Formats
Titles & Footnotes
Object Notes
ContextFormats
Titles & Footnotes
Object Notes
Context
Document Says: “I need Base.Sas.Reg to complete my work.
ODS Says “I have that on file!”
3/15/11 22
REPLAYING OutputProc document name=;
Replay;
Run;
Quit;
3/15/11
Replaying The Documentods html body=<whatever> style=BarrettsBlue; /*for SH */
ods rtf body=<whatever> style=Printer;
ods listing; /* needed for EG, since not turned on by default */
proc document name=nesug.firstdoc (read);
list / order=alpha;
replay / dest=(listing rtf html);
run;
quit;
ods _all_ close;
2
1
3
3/15/11 24
Restricting Output HIDE Command
HIDE PATH; prevents the path and all its subfolders from being replayed
HIDE REG#1;
UNHIDE Command Opposite of Mr. Jekkyl
3/15/11 25
The WHERE statement New as in 9.2 Can condition replay based on
Dates of creation or modification Name of object (and this is why ODS Trace is so helpful) Label of object Pathname of Object By-Groups variables(if original code used BY groups)
Can also be used on file management commands, so we can conditionally LIST.
3/15/11 26
WHERE Statement Variables_CDATE_ Creation Date
_CDATETIME_ Creation Date/Time
_CTIME_ Creation Time
_LABELPATH_ Path Name, in Label format
_MDATE_,_MDATETIME_,_MTIME_
Similar to Cdate* variables, but cover modification time.
_NAME_ Name of current entry. The name is the rightmost entry of the path name.
_PATH_ Pathname of current entry
_SEQNO_ Sequence number of current entry
_TYPE_ Type of object: TABLE or DIRECTORY
Variable name The variable name used as a by group. This is valid only when BY group analysis is used to create the output.
3/15/11 27
WHERE Statement ExamplesExample 4. 1 Searching By Path
list ^(where=(_path_ ? "Height")) / levels=all;
run;/* quit */
Example 4. 2 Tables Only
list ^(where=(_type_ = "Table")) / levels=all;
Example 4. 3 Tables with BY Groups
list ^ (where=(_type_ eq 'Table')) / levels=all bygroups;
^ represents the current directory. Usually can be dropped, but the WHERE statement needs a token before it.
3/15/11 28
WHERE Statement Examples
Example 4 By Group Example:Female Only
list ^ (where=(_type_ = "Table") & (sex="F"))/ levels=all bygroups;
Example 5 Univariate Output, Created Before September 6, 2010.
list Univariate#1(where=(_cdate < '06Sep2010'd));
Example 4. 6 Using ODS Name objects.
list reg#2(where=(_NAME_in ('FitStatistics','ParameterEstimates'));
3/15/11 29
Make your own directories
Create copies and links for faster reporting
Modify Titles, formats, headers, columns, styles without altering output or rerunning original analysis
Combining several reports into one for easy comparison
Enhance output with traffic lighting, but without modifying the original data or defining new formats.s
Intermediate Topics
3/15/11 30
Finding out More Andrew Karp - “A Peek at the Document
Procedure” - SGF 2007 #224 SAS Support ODS Document Tip Sheethttp://support.sas.com/rnd/base/ods/scratch/document-tips.pdf
New from SAS Press:
PROC Document using SAS – Available for Pre-order at NESUG 2011