my ods: real-world uses of modifying table templates steve james centers for disease control and...

32
My ODS: Real- World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga.

Upload: lester-walters

Post on 12-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My ODS: Real-World Uses of Modifying Table

Templates

Steve James

Centers for Disease Control and Prevention

Atlanta, Ga.

Page 2: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga
Page 3: 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

Page 4: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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.

Page 5: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My SASMy SAS

My Proc Contents My Proc Contents

My Proc Freq My Proc Freq

My Proc Contents My Proc Contents

Page 6: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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.

Page 7: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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.

Page 8: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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

+

Page 9: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My Proc ContentsMy Proc Contents

Page 10: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My Proc ContentsMy Proc Contents

List of Variables OnlyList of Variables Only

Remove “The Contents Remove “The Contents Procedure”Procedure”

Page 11: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My Proc FreqMy Proc Freq

Page 12: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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

Page 13: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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.

Page 14: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga
Page 15: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My Proc FreqMy Proc Freq

ODS PATH ODS PATH

SASUSER.TEMPLAT (UPDATE) SASUSER.TEMPLAT (UPDATE)

SASHELP.TMPLMST (READ)SASHELP.TMPLMST (READ)

;;

Page 16: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My Proc FreqMy Proc Freq

ODS PATH ODS PATH

SASUSER.MYTEMPLATES SASUSER.MYTEMPLATES (UPDATE) (UPDATE)

SASHELP.TMPLMST (READ)SASHELP.TMPLMST (READ)

;;

Page 17: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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>

Page 18: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

SASHELP.TMPLMST

Base.Contents.Attributes

Base.Contents.Variables

Base.Freq.OneWayFreqs

Etc.

SASUSER.MYTEMPLATES

My Proc FreqMy Proc Freq

Before Edit

Page 19: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

SASHELP.TMPLMST

Base.Contents.Attributes

Base.Contents.Variables

Base.Freq.OneWayFreqs

Etc.

SASUSER.MYTEMPLATES

Base.Freq.OneWayFreqs

My Proc FreqMy Proc Freq

After Edit

Page 20: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

For Further StudyFor Further Study

Base.Freq.OneWayList

Base.Freq.ListBase.Freq.OneWayFreqs

Parent Template

Child Templates

Base.Freq.FrequencyBase.Freq.Percent

Page 21: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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

Page 22: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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) ;

Page 23: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

My Proc ContentsMy Proc Contents

Page 24: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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

Page 25: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga
Page 26: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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

Page 27: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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

Page 28: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga
Page 29: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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.

Page 30: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

AcknowledgementsAcknowledgements

Cynthia Zender – SAS Institute Cynthia Zender – SAS Institute

Page 31: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

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.

Page 32: My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga

Contact Information: Steve JamesCenters for Disease Control and PreventionMS E-57Atlanta, Ga.

(404) [email protected]