Introduction to SAS/Graph 9.2 Ken Barz [email protected] Colorado Prevention Center 22Oct2009 Ken...
-
Upload
lorraine-parks -
Category
Documents
-
view
217 -
download
1
Transcript of Introduction to SAS/Graph 9.2 Ken Barz [email protected] Colorado Prevention Center 22Oct2009 Ken...
Introduction to SAS/Graph Introduction to SAS/Graph 9.29.2
Introduction to SAS/Graph Introduction to SAS/Graph 9.29.2
Colorado Prevention Center22Oct2009
Colorado Prevention Center22Oct2009
In the Beginning, there wasIn 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
• 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
The “Typical” SAS ProgrammerThe “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
• 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
Learning SAS/Graph 6 – 9.1.3Learning 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 …
• 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 …
The SAS/Graph 9.2 Approach (Do-Overs!)
The 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 destination=PNG file.)
• Full integration with ODS• Output catalogs, grsegs, devices, goptions,
annotate, global statements… all go away
• Template-based graphics as opposed to device-based graphics. (e.g. proc template)
• Default output is to an industry standard (e.g. ODS listing destination=PNG file.)
• Full integration with ODS• Output catalogs, grsegs, devices, goptions,
annotate, global statements… all go away
The SAS/Graph 9.2 Approach (cont: Main Elements)
The 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)
• Proc Template
• Statistical Graphics (SG) Procedures
• ODS Graphics Statement
• ODS Graphics Editor/Designer
• Graph Template Language (GTL)
Learning Proc Template via ODSLearning 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
• 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
(Proc) Template-Based Graphics (SAS 9.2 +)
(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.
• 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.
Minimum Template Code(defaults to sasuser.templat catalog)
Minimum Template Code(defaults to sasuser.templat catalog)
proc template; define statgraph mytemplate; begingraph; layout overlay;
endlayout; endgraph; end;run;
proc template; define statgraph mytemplate; begingraph; layout overlay;
endlayout; endgraph; end;run;
Benefits of Template-Based 9.2 Graphics
Benefits 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
• 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
Statistical Graphics ProceduresStatistical Graphics Procedures
• SGPlot
• SGPanel
• SGScatter
• SGRender
• SGPlot
• SGPanel
• SGScatter
• SGRender
Statistical Graphics Procedures (cont)
Statistical Graphics Procedures (cont)
Support for:
• By group processing
• Formats/Titles/Footnotes/Labels
• ODS Graphics statement manages settings
Support for:
• By group processing
• Formats/Titles/Footnotes/Labels
• ODS Graphics statement manages settings
ODS Graphics StatementODS 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
• 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
The ODS Graphics Editor/Designer (9.2 Phase 2)
The 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
• 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
Graph Template LanguageGraph 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.
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.
Graph Template Language (cont)Graph Template Language (cont)
Graph layout options include:• Overlay• Gridded/Lattice• Datapanel• OverlayEquated• Overlay3D
Graph layout options include:• Overlay• Gridded/Lattice• Datapanel• OverlayEquated• Overlay3D
Graph Template Language (cont)Graph 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.
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.
Graph Template Language (cont)Graph Template Language (cont)
Graph templates also allow the use of:
• Dynamics
• Macro variables
• Conditional logic, expressions and functions
Graph templates also allow the use of:
• Dynamics
• Macro variables
• Conditional logic, expressions and functions
ConclusionConclusion
• 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!
• 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!