ods statistical graphics in sas 9.2 january 17, 2010

33
ODS Statistical Graphics in SAS 9.2 January 17, 2010

Upload: allan-norris

Post on 31-Dec-2015

223 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: ODS Statistical Graphics in SAS 9.2 January 17, 2010

ODS Statistical Graphics in SAS 9.2

January 17, 2010

Page 2: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Prior to SAS 9.2

SAS 9.1 introduced experimental extension to ODS Statistical Graphics (ODS Graphics) in over 20 SAS/STAT and SAS/ETS procedures to create statistical graphics automatically Minimal additional syntax Graphs included scatter plots, histograms and boxplots

Page 3: ODS Statistical Graphics in SAS 9.2 January 17, 2010

New in SAS 9.2

Over 50 procedures in SAS/STAT, SAS/ETS, SAS/QC and Base SAS Produced by default or specification of procedure options

New graph types, ODS styles, point-and-click editor for enhancing titles, labels and other features

Modify graphs via underlying templates in Graph Template Language (GTL)

LISTING destination supported by ODS Graphics New family of ODS Graphics to create standalone plots

(ie. Scatterplots overlaid with smoother) SGRENDER procedure to create customized graphs via

GTL

Page 4: ODS Statistical Graphics in SAS 9.2 January 17, 2010

SAS Graph Gallery

http://support.sas.com/sassamples/graphgallery/index.html

Page 5: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Getting Started

SAS Global Forum 2008 – SAS Presents

(Paper 305-2008)

Getting Started with ODS Statistical Graphics in SAS® 9.2—Revised 2009

by Robert N. Rodriguez, SAS Institute Inc., Cary, NC

http://support.sas.com/rnd/app/papers/intodsgraph.pdf

Page 6: ODS Statistical Graphics in SAS 9.2 January 17, 2010

How can I create a survival plot in SAS?

Specify plot in the PROC LIFETEST using traditional graphics

Specify plot in the PROC LIFETEST with ODS Graphics enabled

Use Graphic Template Language (GTL) Use ODS Graphics Designer

Page 7: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Survival Curve with Traditional Graphics

Survival curveS

urvi

val D

istr

ibut

ion

Fun

ctio

n

0.00

0.25

0.50

0.75

1.00

Time to death (days)

0 100 200 300 400 500 600 700 800

STRATA: partner_excl=A partner_excl=B

Page 8: ODS Statistical Graphics in SAS 9.2 January 17, 2010

ODS Graphics and Default Graphs

Some procedures have graphs associated with them To enable ODS Graphics:

ods graphics on;

proc lifetest data=example.example plots=survival(test atrisk=0 to 730 by 60);

time time2death_2yr*censor_2yr(1);

strata partner_excl;

title 'Survival curve';

run;

Page 9: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Survival Curve with ODS Graphics Enabled(style=default)

Page 10: ODS Statistical Graphics in SAS 9.2 January 17, 2010

ODS RTF (style=journal)

Page 11: ODS Statistical Graphics in SAS 9.2 January 17, 2010

ODS Graphics Templates

Each default graph is controlled by a template written in the Graph Template Language (GTL).

GTL specifies graph layouts (lattices, overlays), types (scatter plots, histograms), titles, footnotes, insets, colors, symbols, lines, etc.

Templates can be modified to customize graphs

Page 12: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Name of the Default Graph Template

ods trace on;

ods graphics on;

proc lifetest data=example.example plots=survival (test atrisk=0 to 730 by 60) outsurv=survest;

time time2death_2yr*censor_2yr(1);

strata partner_excl;

title 'Survival curve';

run;

title;

ods trace off;

Page 13: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Partial LOG file

Page 14: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Source Statements for Template

proc template;

source Stat.Lifetest.Graphics.ProductLimitSurvival;

run;

Source statements output in the LOG file

Page 15: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Before Modifying the Template…

Compiled template is stored in the template item stores Set ODS path to search for templates in the Work item

store

ods path (prepend) work.templat(update);

Any template submitted is stored in Work.Templat is deleted at the end of the SAS session.

Page 16: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Modifying a Template

Modify a template by editing the statements, adding a PROC TEMPLATE statement, and submitting the template source to SAS

Modified template

Page 17: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Modified Template

Page 18: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Changing the STYLE

proc template;

source styles.default;

run;

Source statements for style template

Page 19: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Template Complexity

‘The GTL is a powerful language with many statements and options, and often many different ways to accomplish the same thing. Different procedure writers sometimes found different ways to do the same thing.’…’The template that you see might be very large, complex, and verbose.’…‘When you look at a template, do not expect that you will be able to find some justification for every statement and every option if you only search hard enough. Nor should you expect to find documentation for every option. Some options are deliberately undocumented because they might change in future releases.’

‘Some templates are complex. Others are very complex. Some are much more complex than they need to be for your particular application. However, you do not have to understand most of that complexity. All you have to do is isolate the parts that you want to change, and change those parts while ignoring the surrounding complexity.’

From ‘Modifying ODS Statistical Graphics Templates in SAS® 9.2’ by Warren F. Kuhfeld

Page 20: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Editable Graphs

ods listing sge=on;

proc lifetest data=example.example plots=survival (test atrisk=0 to 730 by 60);

ods select SurvivalPlot;

time time2death_2yr*censor_2yr(1);

strata partner_excl;

title 'Survival Plot';

run;

Page 21: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Generates a SGE file

Page 22: ODS Statistical Graphics in SAS 9.2 January 17, 2010
Page 23: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Modified Template and Edited

Page 24: ODS Statistical Graphics in SAS 9.2 January 17, 2010

ODS Graphics Designer to Create Your Own Templates

pre-production release of the ODS Graphics Designer in SAS® 9.2 Phase 2 provides a GUI interface for building ODS templates for graphs.

A Java application external program using the SAS software environment the SAS data sets used to create templates must be stored as

permanent SAS data sets in accessible libraries.

Page 25: ODS Statistical Graphics in SAS 9.2 January 17, 2010
Page 26: ODS Statistical Graphics in SAS 9.2 January 17, 2010
Page 27: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Survival Plot using SGDESIGN

Page 28: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Survival Plot using SGDESIGN

Example using a different data set Data needs to be set up differently from data used for analysis

Page 29: ODS Statistical Graphics in SAS 9.2 January 17, 2010
Page 30: ODS Statistical Graphics in SAS 9.2 January 17, 2010
Page 31: ODS Statistical Graphics in SAS 9.2 January 17, 2010
Page 32: ODS Statistical Graphics in SAS 9.2 January 17, 2010

Would I start using SAS for graphing?

It depends… How much time do I have?

Do I have to change a template or SAS code?

Page 33: ODS Statistical Graphics in SAS 9.2 January 17, 2010

How not to collaborate with a biostatistician

http://www.xtranormal.com/watch/6878253/