| Overview |
To produce a graph, a GTL template must be bound to a data source using the SGRENDER procedure. The following example uses SGRENDER to bind the SCATTER template to the SAS data set SASHELP.CLASS, which is delivered with the SAS system:
ods listing;
proc sgrender data=sashelp.class
template=scatter;
run;
![]() |
Figure 1.1: Graph produced by the SCATTER template
Generally, an ODS data object is constructed by comparing the template references to column names with variables that exist in the current data set. In the current example, SASHELP.CLASS contains varialbes named HEIGHT and WEIGHT. Because these variable names match the variables that are named on template SCATTER, variables HEIGHT and WEIGHT are added to the data object, while other variables in SASHELP.CLASS are ignored. (It is possible for a template to define new computed columns based on existing columns.)
After all the observations have been read, the data object and template definition are passed to a graph renderer, which produces an image file for the graph. The image file is then automatically integrated into the ODS destination. In this example, a PNG image is created in the LISTING destination. The visual properties of the graph are determined by the ODS style that is in effect.
Note. Template SCATTER is a restrictive definition: it can only create a plot of variables named HEIGHT and WEIGHT. A GTL template can be made more flexible by introducing dynamics or macro variables that supply variables and other information at runtime. For more information, see "Flexible Templates".
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.