can nested layouts. For information about adding a legend or other information
outside of the cells, see “Example 3: A Data Panel with Sidebars” on page 268.
Axis options for classification panels are specified on the LAYOUT
DATALATTICE or LAYOUT DATAPANEL statement, not on the LAYOUT
PROTOTYPE statement. For information about setting axis options for the layout,
see “Managing Axes in DATALATTICE and DATAPANEL Layouts” on page 239.
Distinction between DATAPANEL and
DATALATTICE
The DATAPANEL and DATALATTICE layouts differ in how their classification
variables are declared and in how they populate their cells. For the DATAPANEL
layout, the classification variables are declared as a list of variables in parentheses in the
CLASSVAR= option as shown in the following example.
layout datapanel classvars=(product division) / ...;
The number of class variables in the list is unlimited, though the effectiveness of the
graph decreases as the number of class variables exceeds three or four. In such a case, it
is better to use two class variables, and use the other class variables in the BY statement
of the SGRENDER procedure.
For the DATALATTICE layout, one classification variable is assigned for a row
dimension, and one classification variable is assigned for a column dimension. The row
variable is assigned in the ROWVAR= option, and the column variable is assigned in the
COLUMNVAR= option as shown in the following example.
layout datalattice rowvar=product columnvar=division / ...;
Another key difference between the DATAPANEL and the DATALATTICE layouts is
how they create their cells. The DATAPANEL layout creates a cell for each
classification-variable crossing that produces data. Any crossing that does not produce
data is not included in the panel. Conversely, the DATALATTICE layout creates a cell
for each crossing of its classification variables regardless of whether it produce data. A
crossing the produces no data appears as an empty cell in the lattice. This difference is
significant when analyzing data that is sparse. In that case, the DATAPANEL layout
produces a panel that contains only cells that display data while the DATALATTICE
layout produces a lattice that might contain a large number of empty cells.
Organizing Panel Contents
Overview of What to Consider When Planning a Classification Panel
When planning a classification panel, the following factors influence the layout
specification:
grid dimensions (number of rows and columns)
cell population order as the layout is rendered
gutters between the cells
graph aspect ratio
Organizing Panel Contents 231
cell size within the panel
prototype orientation
Grid Dimensions and Cell Population Order
Assume you want to create a DATAPANEL layout with one classification variable that
has five unique values. Before starting to write code, you must first decide what grid
dimensions you want to set (how many columns and rows) and whether you want to
permit empty cells in the grid. If do not want empty cells, you must limit the grid to five
cells, which gives you two choices for the grid dimensions: five columns by one row
(5x1), or one column by five rows (1x5). If you are willing to have empty cells in the
grid, you could have several grid sizes, such as a 2x3 or a 3x2 grid.
The easiest way to specify a grid dimension is to set both the COLUMNS= and ROWS=
options to the desired number of columns and rows. If one dimension is set, the other
dimension automatically grows to accommodate the number of classification levels. By
default, COLUMNS=1, and the ROWS= option is not set.
By default, the layout uses the ORDER=ROWMAJOR setting to populate grid cells.
This specification essentially means "fill in all cells in the top row (starting at the top
left) and then continue to the next row below." The following layout leaves the default
ORDER=ROWMAJOR setting in effect:
layout datapanel classvars=(var) / columns=3 rows=2;
layout prototype;
... plot statements ...
endlayout;
endlayout;
Here is the resulting grid layout.
Alternatively, you can specify ORDER=COLUMNMAJOR, which populates the grid by
filling in all cells in the left column (starting at the top), and then continuing with the
next column:
layout datapanel classvars=(var) / columns=3 rows=2 order=columnmajor;
layout prototype;
... plot statements ...
endlayout;
endlayout;
232 Chapter 13 Creating Classification Panels Using the DATALATTICE and DATAPANEL Layouts

Get SAS 9.4 Graph Template Language, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.