ODS Statistical Graphics is the Output Delivery System (ODS) graphics architecture in SAS that generates analytical charts, diagnostic plots, and publication-grade figures through graph templates, ODS styles, and dedicated procedures rather than legacy device-dependent graphics catalogs. Built directly onto the ODS infrastructure, ODS Statistical Graphics enables both statistical procedures (such as regression, survival, and ANOVA procedures) and standalone SG procedures (PROC SGPLOT, PROC SGPANEL, PROC SGSCATTER, and PROC SGRENDER) to render clean figures directly into modern destinations like HTML, PDF, RTF, and image files. Across clinical reporting, statistical modeling, risk analytics, and business intelligence, ODS Statistical Graphics provides consistent styling, automatic legends, and reproducible code.
How ODS Statistical Graphics Differs from Legacy SAS Graphics
Traditional SAS/GRAPH workflows relied heavily on global statements (GOPTIONS, AXIS, LEGEND, PATTERN, SYMBOL), device drivers, and graphics segments (GRSEG) stored inside SAS catalogs—an approach that required extensive tuning and often felt awkward when exporting reports to office documents.
ODS Statistical Graphics modernizes visual production in several practical ways:
- Template-Driven Rendering: Graphs are constructed from underlying templates—written in the Graph Template Language (GTL)—that define layout, plot primitives, axes, and legends.
- Style-Coordinated Appearance: Fonts, colors, marker symbols, and line patterns inherit cleanly from the active ODS style, keeping graphics visually aligned with surrounding tables and text in HTML, PDF, or RTF output.
- Seamless Integration with Statistical Procedures: Many analytical procedures automatically emit diagnostic and summary plots when ODS Graphics is active, eliminating extra steps to inspect fits, residuals, or survival curves.
Core SG Procedures and Graph Template Language (GTL)
Most analysts interact with ODS Statistical Graphics through four core procedures:
| Procedure / Tool | Primary Role | Key Strengths & Typical Use Cases | Key Consideration |
|---|---|---|---|
PROC SGPLOT | Single-cell plots and overlaid charts on one coordinate system | Scatter, series, band, histogram, density, box, needle, and fit overlays; XAXIS, YAXIS, Y2AXIS, INSET | Best for single-frame charts and multi-series overlays |
PROC SGPANEL | Multi-cell paneled graphs driven by classification variables | PANELBY layouts (PANEL, LATTICE, COLUMNLATTICE, ROWLATTICE) with ROWAXIS and COLAXIS | Does not support X2AXIS / Y2AXIS in standard paneled layouts |
PROC SGSCATTER | Panels of scatter plots and scatter plot matrices | PLOT, COMPARE, and MATRIX layouts with optional fit/confidence overlays | Specialized for multi-variable scatter comparisons; less flexible single-plot tuning than SGPLOT |
PROC SGRENDER + GTL | Custom multi-layout templates defined via PROC TEMPLATE | Fine-grained control over lattice grids, custom annotations/tables, and reusable templates | Higher syntax complexity than SGPLOT or SGPANEL |
For custom layouts—such as complex multi-panel clinical figures or bespoke summary layouts—analysts define a STATGRAPH template using PROC TEMPLATE in GTL and render it with PROC SGRENDER. Interactive tools such as ODS Graphics Designer (producing .SGD files replayable with PROC SGDESIGN) can also help prototype layouts visually before or alongside scripted workflows.
Controlling Output with the ODS GRAPHICS Statement
Because ODS Statistical Graphics is tied to the Output Delivery System, an active ODS destination must be open to capture output, and the ODS GRAPHICS statement controls global rendering behavior:
- Enabling or Disabling: ODS Graphics is enabled by default in modern SAS releases (such as SAS 9.4 and SAS Viya), and can be toggled with
ODS GRAPHICS ON;orODS GRAPHICS OFF;. - Image Format and Naming: Options such as
IMAGEFMT=(e.g., PNG, PDF, SVG) andIMAGENAME=control file format and base file names when writing standalone graphics files. - Dimensions and Resolution: Controlling width, height, and DPI (such as
IMAGE_DPI=on the listing destination) helps figures meet print, slide, or regulatory submission clarity standards.
Practical Workflow and Best Practices
A clean ODS Statistical Graphics workflow keeps data preparation separate from visual styling:
- Shape and Format Data First: Aggregate, sort, and format variables (such as dates, quarters, currency, or group labels) in a
DATAstep orPROC SQLbefore plotting so axes and legends display cleanly. - Start with
SGPLOTorSGPANEL: UsePROC SGPLOTfor focused single-panel charts and overlays, andPROC SGPANELwhen comparing distributions or trends across classification levels. - Use Direct Labels, Reference Lines, and Insets Thoughtfully: Add clear axis labels, gridlines, group attributes (
STYLEATTRS/ contrast colors), and conciseINSETcallouts without crowding the data area. - Escalate to GTL Only When Needed: Reserve
PROC TEMPLATEandPROC SGRENDERfor specialized multi-cell structures or custom layouts thatSGPLOTandSGPANELcannot express directly.
Conclusion
ODS Statistical Graphics gives SAS programmers a unified, reproducible way to move from statistical computation to clear visual communication. By pairing concise SG procedures and GTL templates with ODS styles and destinations, analysts can produce consistent, readable graphics across exploratory analysis, model diagnostics, and formal reporting.