A Quick Example
The SASHELP.CLASS data set that is delivered with the SAS System includes data columns named HEIGHT and WEIGHT, which store hieght and weight measures for a small sample of subjects. The Graphics Template Language can be used to generate a histogram that shows the frequency count of the heights recorded in that data sample:

The following SAS program produces the graph:
proc template;
define statgraph histogram;
begingraph;
layout overlay;
histogram weight;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class
template=histogram;
run;
- The DEFINE STATGRAPH statement on PROC TEMPLATE opens a definition block for defining an graphics template named HISTOGRAM that is stored in the template folder (also called the template store , by default located in SASUSER.TEMPLAT).
- The template definition for HISTOGRAM specifies two GTL statements within a BEGINGRAPH/ENDGRAPH block: LAYOUT OVERLAY and HISTOGRAM.
- The LAYOUT OVERLAY statement is one of the most fundamental layout statements. It can overlay the results of one or more plot statements, each of which will share the same plot area, axes, and legends. The layout in this example specifies only a single element: a HISTOGRAM that generates frequency counts for values in a data column named WEIGHT.
- The END LAYOUT statement ends the layout block, the ENDGRAPH statement ends the graph definition, and the END statement ends the template definition.
- The DATA= option on PROC SGRENDER specifies SASHELP.CLASS as the data source for the graph. TEMPLATE= specifies HISTOGRAM as the template definition to use for rendering the graph.
 |
 |
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.