Paper 218-2009
GTL (Graphics Template Language) in SAS® 9.2
Philip R Holland, Holland Numerics Limited, Royston, Herts UK
ABSTRACT
The production version of the GTL (Graphics Template Language) was introduced in SAS
®
9.2. This new language
gives all users the ability to create high-quality graphs using simple ODS Graph templates and structured data. This
paper describes how to get started with this new language by developing some typical graphs for publication.
GTL BASICS
GTL is a subset of the PROC TEMPLATE statements used in the STATGRAPH templates. An experimental version
was included in SAS 9.1.3, but this was not complete, and has been altered and updated for the production version in
SAS 9.2, so that templates written in SAS 9.1.3 are not compatible with SAS 9.2.
The basic STATGRAPH template is made up of nested structures:
DEFINE STATGRAPH name; – create the template
DYNAMIC name(s); – define any parameters (optional)
COLUMN names(s); – define any SAS variable parameters by name (optional)
BEGINGRAPH; – start the graph (new in SAS 9.2!)
ENTRYTITLE title; – create a title (can be repeated for additional titles)
LAYOUT – at least one layout statement is required
LAYOUT – nested layout statements (optional)
Any plot statements, including titles, graph areas, footnotes, etc.
ENDLAYOUT;
Any plot statements, including titles, graph areas, footnotes, etc.
ENDLAYOUT;
ENTRYFOOTNOTE footnote; – create a footnote (can be repeated for additional footnotes)
ENDGRAPH;
END;
Layout statements include:
• LAYOUT GRIDDED – create a grid of graph cells with the same dimensions and properties.
• LAYOUT LATTICE – create a grid of graph cells with different dimensions and properties.
• LAYOUT OVERLAY – create a single graph cell with one or more overlaid plots.
Plot statements include:
• SERIESPLOT – create a plot of connected points.
• SCATTERPLOT – create a plot of symbols at specified points.
• NEEDLEPLOT – create a plot of vertical lines joining a horizontal axis line to specified points.
• LINEPARM – draw a line on the graph with a specified starting position and slope.
• DISCRETELEGEND – create a legend.
1
Re
ortin
and Information Visualization