| BEGINGRAPH Statement |
The following graph was generated by the "Example Program":

proc template;
define statgraph begingraph;
dynamic XVAR YVAR;
begingraph / designwidth=640px designheight=320px;
layout lattice / columns=2;
layout overlayequated / equatetype=square;
entry "Linear Regression Fit" /
valign=top texttattrs=(weight=bold);
scatterplot x=XVAR y=YVAR / datatransparency=.5;
regressionplot x=XVAR y=YVAR;
endlayout;
layout overlayequated / equatetype=square;
entry "Loess Fit" /
valign=top texttattrs=(weight=bold);
scatterplot x=XVAR y=YVAR / datatransparency=.5;
loessplot x=XVAR y=YVAR;
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.iris template=begingraph;
dynamic title="Square Plot"
xvar="SepalLength" yvar="SepalWidth";
run;
Within a BEGINGRAPH block, at least one statgraph-layout-block is required. It may be a LATTICE, GRIDDED, OVERLAY, OVERLAYEQUATED, OVERLAY3D, DATALATTICE, or DATAPANEL layout block. This layout block should contain at least one plot statement.
The statgraph-global-statements include one or more ENTRYTITLE, ENTRYFOOTNOTE, or IF / ELSEIF/ ELSE statements. Any of these global statements may precede or follow the statgraph-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 "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, thus ensuring 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 on the ODS GRAPHICS statement. Size settings on the ODS GRAPHICS statement override size settings on 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), which is designated 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;
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.