ODS Statistical Graphics in SAS 9.2

Download Report

Transcript ODS Statistical Graphics in SAS 9.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
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
SAS Graph Gallery
http://support.sas.com/sassamples/graphgallery/index.html
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
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
Survival Curve with Traditional Graphics
Survival curve
1.00
Survival Distribution Function
0.75
0.50
0.25
0.00
0
100
200
300
400
500
Time to death (days)
STRATA:
partner_excl=A
partner_excl=B
600
700
800
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;
Survival Curve with ODS Graphics Enabled
(style=default)
ODS RTF (style=journal)
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
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;
Partial LOG file
Source Statements for Template
proc template;
source
Stat.Lifetest.Graphics.ProductLimitSurvival;
run;

Source statements output in the LOG file
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.
Modifying a Template

Modify a template by editing the statements, adding a
PROC TEMPLATE statement, and submitting the
template source to SAS

Modified template
Modified Template
Changing the STYLE
proc template;
source styles.default;
run;

Source statements for style template
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
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;
Generates a SGE file
Modified Template and Edited
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.
Survival Plot using SGDESIGN
Survival Plot using SGDESIGN

Example using a different data set

Data needs to be set up differently from data used for analysis
Would I start using SAS for graphing?

It depends…
 How
 Do
much time do I have?
I have to change a template or SAS code?
How not to collaborate with a
biostatistician
http://www.xtranormal.com/watch/6878253/