19
Introduction to Introduction to SAS/Graph 9.2 SAS/Graph 9.2 Ken Barz [email protected] Colorado Prevention Center 22Oct2009

Introduction to SAS/Graph 9.2 Ken Barz [email protected] Colorado Prevention Center 22Oct2009 Ken Barz [email protected] Colorado Prevention Center

Embed Size (px)

Citation preview

Page 1: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

Introduction to SAS/Graph Introduction to SAS/Graph 9.29.2

Introduction to SAS/Graph Introduction to SAS/Graph 9.29.2

Ken [email protected]

Colorado Prevention Center22Oct2009

Ken [email protected]

Colorado Prevention Center22Oct2009

Page 2: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 3: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 4: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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 …

Page 5: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 6: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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)

Page 7: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 8: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

(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.

Page 9: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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;

Page 10: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 11: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

Statistical Graphics ProceduresStatistical Graphics Procedures

• SGPlot

• SGPanel

• SGScatter

• SGRender

• SGPlot

• SGPanel

• SGScatter

• SGRender

Page 12: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 13: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 14: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 15: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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.

Page 16: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 17: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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.

Page 18: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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

Page 19: Introduction to SAS/Graph 9.2 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center 22Oct2009 Ken Barz Ken.barz@cpcmed.org Colorado Prevention Center

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!