SAS Institute. The Power to Know

SAS/GRAPH(R) 9.2: Graph Template Language Reference

Previous | Next
LAYOUT GRIDDED Statement

Example Program and Statement Details

The following graph was generated by the "Example Program":


layoutgriddedintro image

Example Program

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 will 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;
 

Statement Summary

A GRIDDED layout is commonly used to create small tables of text that are nested within other layouts. The layout might also be used to span and center a single entry (a legend, for example) across a set of grids, or to display a grid of graphs when there is no need to scale the data ranges on the axes or align the parts of the graphs across grid cells.

The GRIDDED layout automatically decides how much area to allocate to cell contents:

  • text items have a fixed size based on the amount of text and the font properties
  • graphs take up the remaining space.

The layout's grid size is determined by the COLUMNS= and ROWS= options. The resulting columns and rows can be separated by areas called gutters , which are controlled by the COLUMNGUTTER= and ROWGUTTER= options.

By default, the results of the statgraph-statements are placed into the grid sequentially from left to right, wrapping to a new row each time the current row is filled. You can use the ORDER= option to fill cells from top to bottom down a column, in which case the layout cells wrap to a new column each time the current column is filled.


Options

Previous | Next | Top of Page