SAS Institute. The Power to Know

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

Previous | Next
LAYOUT DATALATTICE Statement

Example Program and Statement Details

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


layoutdatalatticeintro image

Example Program

This example shows the result of using row and column classification variables. In this case, a four-column, three-row data lattice is created:
  • The classification values are placed as row or column labels by default.
  • The ROWDATARANGE = UNION option assures that an axis range is computed separately for each row using the data ranges of all Y= variables in that row. This facilitates the visual comparison of the data cells.
  • A SIDEBAR block is used to place the legend at the bottom of the lattice.
  
 proc template; 
  define statgraph layoutdatalattice; 
   begingraph; 
     entrytitle "Annual Furniture Sales Comparisons"; 
     layout datalattice rowvar=country columnvar=year / 
       rowdatarange=union 
       headerlabeldisplay=value 
       headerbackgroundcolor=GraphAltBlock:color 
       rowaxisopts=(display=(tickvalues) griddisplay=on 
         linearopts=(tickvalueformat=dollar12.)) 
       columnaxisopts=(display=(tickvalues) 
         timeopts=(tickvalueformat=monname3.)); 
       layout prototype / cycleattrs=true; 
         seriesplot x=month y=TotalActual / name="Actual"; 
         seriesplot x=month y=TotalPredict / name="Predict"; 
       endlayout; 
       sidebar / align=bottom; 
         discretelegend "Actual" "Predict" / border=false; 
       endsidebar; 
     endlayout; 
   endgraph; 
  end; 
 run; 
  
 proc summary data=sashelp.prdsal2 nway; 
   class country year month; 
   var actual predict; 
   output out=prdsal2 sum=TotalActual TotalPredict; 
 run; 
  
 proc sgrender data=prdsal2 template=layoutdatalattice; 
 run;
 

Statement Summary

The LAYOUT DATALATTICE statement makes it easy to create a grid of graphs, based on the values of one or two classifications variables. To create a grid that is based on more than two classification variables, or to have more control over the grid layout, use LAYOUT DATAPANEL instead.

By default, the number of cells in the layout is determined by the number of value pairings that are possible for the classification values plus any empty cells needed to complete the last row/column of the grid. The contents of each data cell are based on a graph prototype that you specify in the graph-prototype-block . Optionally, you can enhance the display using one or more sidebar-statement-blocks . For classification variables that have many values, you can use the COLUMNS= and/or ROWS= options and the PANELNUMBER= option to generate multiple panel displays.

Classification variables for the layout are specified on the ROWVAR= argument (to specify a row variable), or the COLUMNVAR= argument (to specify a column variable), or both arguments to specify both a column and a row variable. The graph prototype for each data cell's contents is specified within a LAYOUT PROTOTYPE block, and sidebars are specified within SIDEBAR blocks. The LAYOUT PROTOTYPE and SIDEBAR blocks are nested within the LAYOUT DATALATTICE block.

By default, the first data cell to be filled is in the layout's top-left corner. Use the START= option to change the starting data cell to the bottom-left corner.

Rather than display the header labels outside the grid, you can set HEADERLABELLOCATION=INSIDE to display them inside the grid, as shown in the following figure:


layoutdatalatticeinside image


Note: The DATALATTICE layout is designed to be the outermost layout in the template.


Required Argument(s)

Prototype Block

Sidebar Blocks

Options

Previous | Next | Top of Page