Title: Introduction to SAS/Graph 9.2
1Introduction to SAS/Graph 9.2
- Ken Barz
- Ken.barz_at_cpcmed.org
- Colorado Prevention Center
- 22Oct2009
2In the Beginning, there was
- Base SAS Proc plot
- listing output only
- Think stick figures on a line printer
- SAS/Graph 6-9.1.3 proc gplot
- ODS output as of SAS 8
- Color graphics, sometimes crude, extra
- Complex ? steep learning curve
3The Typical SAS Programmer
- Knowledge of data and proc steps
- Able to use libname, filename, title and footnote
statements - Statistical and reporting procedures
- Maybe some ODS and macro language
4Learning SAS/Graph 6 9.1.3
- Open code vs. run groups
- Catalogs, grseg files, SAS registry, and hardware
devices. - Options, goptions, greplay, symbols, axes,
legends, line types, interpolation parameters,
fonts, ODS, annotate, and
5The SAS/Graph 9.2 Approach (Do-Overs!)
- Template-based graphics as opposed to
device-based graphics. (e.g. proc template) - Default output is to an industry standard (e.g.
ODS listing destinationPNG file.) - Full integration with ODS
- Output catalogs, grsegs, devices, goptions,
annotate, global statements all go away
6The SAS/Graph 9.2 Approach (cont Main Elements)
- Proc Template
- Statistical Graphics (SG) Procedures
- ODS Graphics Statement
- ODS Graphics Editor/Designer
- Graph Template Language (GTL)
7Learning Proc Template via ODS
- Learn the majority of ODS
- Use ODS Trace to determine SAS output objects
- Learn the capabilities and syntax of proc
template - Figure out how to combine it all
8(Proc) Template-Based Graphics (SAS 9.2 )
- Output is produced from a compiled ODS template
of type STATGRAPH (other types include TABLE,
COLUMN, FOOTER, HEADER, CROSSTABS, CELLVALUE,
STYLE, TAGSET) - Statistical Graphics procedures use templates
(sgplot, sgpanel, ) provided by SAS - Custom templates may be created with Proc
Template, the Graphics Template Language (GTL)
and Proc sgrender.
9Minimum Template Code(defaults to
sasuser.templat catalog)
- proc template
- define statgraph mytemplate
- begingraph
- layout overlay
- endlayout
- endgraph
- end
- run
10Benefits of Template-Based 9.2 Graphics
- Graphics are clean, easy to code and produce
- Sizing determined by aspect ratio, not hardware
device - Tight integration with ODS, Styles and
RTF/Unicode syntax - Attributes cycle automatically
- Complex output is easily achieved
11Statistical Graphics Procedures
- SGPlot
- SGPanel
- SGScatter
- SGRender
12Statistical Graphics Procedures (cont)
- Support for
- By group processing
- Formats/Titles/Footnotes/Labels
- ODS Graphics statement manages settings
13ODS Graphics Statement
- Controls the runtime environment for producing
template-based graphs - Similar to the old goptions statement (with fewer
options) - Options for reset, size, image name and format,
scale, dpi, antialiasing, - Enables the creation of default Statistical
Procedure graphs
14The ODS Graphics Editor/Designer (9.2 Phase 2)
- Interactively add, edit or delete titles,
footnotes, super/subscripts, labels, lines,
symbols, - Change the style or the size of the graph
- Add annotation to the graph
- Available within SAS or as a stand-alone
downloadable application
15Graph Template Language
- Creating a graph using GTL involves
- Defining the structure of the graph using the GTL
syntax in a STATGRAPH template that is specified
on the TEMPLATE procedure. - Creating the graph by running the SGRENDER
procedure to associate the appropriate data with
the template.
16Graph Template Language (cont)
- Graph layout options include
- Overlay
- Gridded/Lattice
- Datapanel
- OverlayEquated
- Overlay3D
17Graph Template Language (cont)
- Graph templates allow customization of
- Titles, footnotes, row and column headers,
sidebars and text entries. - Linear, time and log axes.
- Styles and attributes.
- Appearance of grouped and non-grouped data.
18Graph Template Language (cont)
- Graph templates also allow the use of
- Dynamics
- Macro variables
- Conditional logic, expressions and functions
19Conclusion
- In version 9.2, SAS/Graph has been completely
re-written to a template-based orientation. - Clean and intricate graphs can now be produced
via a straight forward coding method. - The old approaches to SAS/Graph still mostly work
as well. - Thank you!