my ods: real-world uses of modifying table templates steve james centers for disease control and...
TRANSCRIPT
My ODS: Real-World Uses of Modifying Table
Templates
Steve James
Centers for Disease Control and Prevention
Atlanta, Ga.
GoalsGoals
See useful examples of See useful examples of modifying procedure outputmodifying procedure output
Trigger your thoughts of how Trigger your thoughts of how it could help youit could help you
Motivate you to pursue your Motivate you to pursue your own study of table templatesown study of table templates
My SASMy SAS
Too much output from Proc Too much output from Proc ContentsContents
Proc Freq frequencies don’t use a Proc Freq frequencies don’t use a comma format.comma format.
““The FREQ Procedure” on the The FREQ Procedure” on the output.output.
My SASMy SAS
My Proc Contents My Proc Contents
My Proc Freq My Proc Freq
My Proc Contents My Proc Contents
ODS BasicsODS Basics
OutputOutputObjectObject
SAS® process or procedure creates one or more output objects.
ODS statements route object(s) to destination.
Output Object is composed of a data component and for most procedures, a template component.
ODS BasicsODS Basics– Some procedures might have only a Some procedures might have only a
single output object, whereas others single output object, whereas others have multiple output objects.have multiple output objects.
– ODS stores a link to each output object ODS stores a link to each output object in the Results folder, displayed in the Results folder, displayed interactively in the Results window.interactively in the Results window.
PROC PRINT has one output object. PROC UNIVARIATE has multiple output objects.
ODS BasicsODS BasicsAn An output objectoutput object is an object that contains both is an object that contains both– the results of a Data step or PROC stepthe results of a Data step or PROC step– information about how to format the resultsinformation about how to format the results
DataComponent
Table Template
OutputObject
+
My Proc ContentsMy Proc Contents
My Proc ContentsMy Proc Contents
List of Variables OnlyList of Variables Only
Remove “The Contents Remove “The Contents Procedure”Procedure”
My Proc FreqMy Proc Freq
My Proc FreqMy Proc Freq
Frequency is formatted with a Frequency is formatted with a comma10. formatcomma10. format
Percent has a percent (%) sign Percent has a percent (%) sign addedadded
Column headings are customizedColumn headings are customized
My Proc FreqMy Proc Freq
Table Template Storage Table Template Storage
It is a type of SAS file called a It is a type of SAS file called a template store. template store. SAS Institute SAS Institute provides a template store called provides a template store called TMPLMST in the SASHELP TMPLMST in the SASHELP directory. directory.
My Proc FreqMy Proc Freq
ODS PATH ODS PATH
SASUSER.TEMPLAT (UPDATE) SASUSER.TEMPLAT (UPDATE)
SASHELP.TMPLMST (READ)SASHELP.TMPLMST (READ)
;;
My Proc FreqMy Proc Freq
ODS PATH ODS PATH
SASUSER.MYTEMPLATES SASUSER.MYTEMPLATES (UPDATE) (UPDATE)
SASHELP.TMPLMST (READ)SASHELP.TMPLMST (READ)
;;
My Proc FreqMy Proc Freq
proc template ;proc template ;
define define Base.Freq.OneWayFreqs ;Base.Freq.OneWayFreqs ;
<complete definition><complete definition>
edit Base.Freq.OneWayFreqs ;edit Base.Freq.OneWayFreqs ; <code for items to change><code for items to change>
SASHELP.TMPLMST
Base.Contents.Attributes
Base.Contents.Variables
Base.Freq.OneWayFreqs
Etc.
SASUSER.MYTEMPLATES
My Proc FreqMy Proc Freq
Before Edit
SASHELP.TMPLMST
Base.Contents.Attributes
Base.Contents.Variables
Base.Freq.OneWayFreqs
Etc.
SASUSER.MYTEMPLATES
Base.Freq.OneWayFreqs
My Proc FreqMy Proc Freq
After Edit
For Further StudyFor Further Study
Base.Freq.OneWayList
Base.Freq.ListBase.Freq.OneWayFreqs
Parent Template
Child Templates
Base.Freq.FrequencyBase.Freq.Percent
For Further StudyFor Further Study
Common.ANOVA.DF
SASHELP.TMPLMST
Stat.Discrim.DF
Stat.Discrim.ANOVAcontains DF column
Which inherits from parent columnWhich inherits from grandparent column
Stat.GLM.ANOVA contains DF column
My Proc FreqMy Proc Freq
Return to Default Behavior?Return to Default Behavior?
proc template ; proc template ; delete delete Base.Freq.OneWayFreqs ;Base.Freq.OneWayFreqs ;
ods path sashelp.tmplmst ods path sashelp.tmplmst (read) ;(read) ;
My Proc ContentsMy Proc Contents
My Proc ContentsMy Proc Contents
One Table of Output with:One Table of Output with:
– Selected Attribute and Selected Attribute and EngineHost InformationEngineHost Information
– Selected Variable InformationSelected Variable Information
My Proc ContentsMy Proc Contents
1.1. Modify existing table template Modify existing table template with the changes we want:with the changes we want:
– Attribute info in the headerAttribute info in the header– Combine type/length and Combine type/length and
format/informat columnsformat/informat columns– Engine/Host info in the footerEngine/Host info in the footer– Use macro variables Use macro variables
My Proc ContentsMy Proc Contents
2. Create a macro that:2. Create a macro that:– Runs Proc Contents, storing Runs Proc Contents, storing
output objects as SAS output objects as SAS datasetsdatasets
– Reads SAS datasets and store Reads SAS datasets and store info in macro variables.info in macro variables.
– Run Proc Contents again Run Proc Contents again using new table templateusing new table template
ConclusionConclusion
ODS allows you to add much ODS allows you to add much more customization to your more customization to your output simply and easily. output simply and easily.
AcknowledgementsAcknowledgements
Cynthia Zender – SAS Institute Cynthia Zender – SAS Institute
Trademark CitationTrademark Citation
SAS is a registered trademark SAS is a registered trademark or trademark of SAS Institute or trademark of SAS Institute Inc. in the USA and other Inc. in the USA and other countries. countries.
® indicates USA registration.® indicates USA registration.
Contact Information: Steve JamesCenters for Disease Control and PreventionMS E-57Atlanta, Ga.
(404) [email protected]