Minimum Requirements to Generate a Plot

ODS graphics are generated by template definitions that determine a graph’s layout and appearance and specify the variable roles to be represented in the graph display. A graph can be rendered from a compiled template by associating the template with a data source at run time.
The following SAS program shows the basic structure needed to meet the minimum requirements for generating a plot using GTL:
proc template;
  define statgraph minimumreq;
    begingraph;
      layout overlay;
        scatterplot x=weight y=height;
      endlayout;
    endgraph;
  end;
run;

proc sgrender data=sashelp.class template=minimumreq;
run;
  • The DEFINE STATGRAPH statement on PROC TEMPLATE is required to open a definition block for defining and naming a graphics template. The END statement closes the template definition.
  • A BEGINGRAPH statement block is required to define the outermost container for the graph. The ENDGRAPH statement closes the block.
  • At least one layout statement block is required for specifying the elements that compose the graph. To generate a plot, the layout block must contain at least one plot statement. The ENDLAYOUT statement closes the layout block.
  • The PROC TEMPLATE statement must be run to compile the template and save it in the template store (SASUSER.TEMPLAT by default).
  • The PROC SGRENDER statement is required to produce a graph from a compiled template. The DATA= option specifies a run-time data source to use, and the TEMPLATE= option specifies the template to use. The input data source must satisfy any restrictions that are imposed by the template. For example, it must contain any variables that have been specified on the template’s GTL statements.