The GRIDDED
layout offers the best way to nest a table of information inside another
layout. In the GRIDDED layout, you can control the content, text justification,
and fonts of columns. Because this example nests the GRIDDED layout
within an OVERLAY layout, you can control where it appears within
the plot area. The AUTOALIGN= option enables you to specify a prioritized
list of possible positions where the layout should be drawn. The position
actually used is the first one that avoids collision with the histogram.
Also, the GRIDDED layout is set to be opaque so that the grid lines
do not show through.
This example
also illustrates a reusable template in the sense that it works for
any numeric variable specified by the dynamic variable VAR. Also,
SGE functions for computing the N, MEAN, STDDEV of the variable are
used in the table to compute the statistics as the template is executed.
proc template;
define statgraph inset;
dynamic VAR;
begingraph;
entrytitle "Distribution of " VAR;
layout overlay / yaxisopts=(griddisplay=on);
histogram VAR / scale=percent;
layout gridded / columns=2
autoalign=(topleft topright) border=true
opaque=true backgroundcolor=GraphWalls:color;
entry halign=left "N";
entry halign=left eval(strip(put(n(VAR),12.0)));
entry halign=left "Mean";
entry halign=left eval(strip(put(mean(VAR),12.2)));
entry halign=left "Std Dev";
entry halign=left eval(strip(put(stddev(VAR),12.2)));
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=inset;
dynamic VAR="Weight";
run;