All template
definitions in the Graphics Template Language must start with a BEGINGRAPH
statement and conclude with an ENDGRAPH statement.
Within
a BEGINGRAPH block, at least one
GTL-layout-block is required. It can be a LATTICE, GRIDDED, OVERLAY, OVERLAYEQUATED,
OVERLAY3D, DATALATTICE, or DATAPANEL layout block. This layout block
should contain at least one plot statement.
The
GTL-global-statements include one or more ENTRYTITLE,
ENTRYFOOTNOTE, or IF / ELSEIF/ ELSE statements. Any of these global
statements can precede or follow the
GTL-layout-block.
By default,
graphs are rendered at 640px by 480px (4:3 aspect ratio). To change
the graph size for the output of a single BEGINGRAPH block, use the
DESIGNWIDTH= and
DESIGNHEIGHT= options on that BEGINGRAPH statement.
For example, the template in the
Example Program uses DESIGNHEIGHT= to change the graph height to 320px.
To prevent the graph width from automatically scaling to preserve
the 4:3 aspect ratio, it uses DESIGNWIDTH= to maintain the 640px width.
The setting ensures that each graph cell is square (320px by 320px).
Note: To change the
graph sizes for all templates in the current SAS session, use the
WIDTH= and HEIGHT= options in the ODS GRAPHICS statement. Size settings
in the ODS GRAPHICS statement override size settings in the BEGINGRAPH
statement and remain in effect unless they are changed on another
ODS GRAPHICS statement.
The following
template defines a square graph (equal height and width, 1:1 aspect
ratio) by setting the design width equal to the internal default height
(480px). The setting is made with DESIGNWIDTH=DEFAULTDESIGNHEIGHT:
proc template;
define statgraph squareplot;
dynamic title xvar yvar;
begingraph / designwidth=defaultDesignHeight;
entrytitle title;
layout overlayequated / equatetype=square;
scatterplot x=xvar y=yvar;
regressionplot x=xvar y=yvar;
endlayout;
endgraph;
end;
run;
If this
template were executed with the following GRENDER procedure statement,
a 480px by 480px graph would be created:
proc sgrender data=mydata template="squareplot" ;
dynamic title="Square Plot" xvar="time1" yvar="time2";
run;
If the
ODS GRAPHICS statement’s WIDTH= or HEIGHT= options change the
design width or design height, the
squareplot template’s 1:1 aspect ratio would still be honored. Thus,
both of the following GRENDER procedure statements would create a
550px by 550px graph:
ods graphics / width=550px;
proc sgrender data=mydata template="squareplot" ;
dynamic title="Square Plot" xvar="time1" yvar="time2";
run;
ods graphics / height=550px;
proc sgrender data=mydata template="squareplot" ;
dynamic title="Square Plot" xvar="time1" yvar="time2";
run;