Graphics are an indispensable part of statistical analysis.
Graphics reveal patterns, identify differences, and provoke meaningful
questions about your data. Graphics add clarity to an analytical presentation
and stimulate deeper investigation.
SAS
9.2 introduced the Graph Template Language (GTL), a powerful new language
for defining clear and effective statistical graphics. The GTL enables
you to generate various types of plots, such as model fit plots, distribution
plots, comparative plots, prediction plots, and more.
The GTL applies
accepted principles of graphics design to produce plots that are clean
and uncluttered. Colors, fonts, and relative sizes of graph elements
are designed for optimal impact. By default, the GTL produces PNG
files, which support true color (the full 24-bit RGB color model)
and enable visual effects such as anti-aliasing and transparency.
A PNG file retains a small file size. GTL statement options enable
you to control the content and appearance of the graphic down to the
smallest detail.
The GTL is designed
to produce graphics with minimal syntax. The GTL uses a flexible,
building-block approach to create a graph by combining statements
in a StatGraph template. StatGraph templates are defined with the
TEMPLATE procedure.
You
can create custom graphs by defining your own StatGraph templates.
To create a custom graph, you must perform the following steps:
-
Define a StatGraph template
with the TEMPLATE procedure.
-
Use the GTL to specify
the parameters of your graph.
-
Associate your data
with the template using the SGRENDER procedure.
With just a few statements,
you can create the graphs that you need to analyze your data. For
example, you can create the following model fit plot with these statements:
proc template;
define statgraph mytemplate;
beginGraph;
entrytitle "Model Weight by Height";
layout overlay;
bandplot x=height limitupper=upper limitlower=lower;
scatterplot y=weight x=height;
seriesplot y=predict x=height;
endlayout;
endGraph;
end;
run;
proc sgrender data=sashelp.classfit
template=mytemplate;
run;
The previous example
defines a StatGraph template named MyTemplate, which uses values from
the data set Sashelp.Classfit. This data set contains the data variables
HEIGHT and WEIGHT and precomputed values for the fitted model (Y=PREDICT
)
and confidence band (limitupper=upper limitlower=lower
).
The SGRENDER procedure uses the data in Sashelp.Classfit and the MyTemplate
template to render the graph. (This example is member GTLMFIT1 in
the SAS Sample Library.)
The following two graphics
are more examples of what you can do with ODS graphics: