Tables and axes > Include and substitution > Grid tables > Cross-tabulating grid axes
 
Cross-tabulating grid axes
Quick reference
To create a table from a grid axis, type:
tab axis_name grid [;options]
to create rows and columns as they appear in the axis definition, or:
tab axis_name rgrid [;options]
to rotate it by 90 degrees, so the row definitions become the columns, and the column definitions become the rows).
Grid tables are the only time that the tab statement can be followed by a single axis name only. To produce a table in which the rows and columns are as defined in the grid axis, type:
tab axis_name grid [;options]
where axis_name is the name of the grid axis and grid is a keyword indicating that this is a grid table. Since this is so, it follows that you cannot have an axis called grid. Options can be any of the keywords listed in Options on a, sectbeg, flt and tab statements or in Options on the tab statement.
Normally, a grid table is created using the row and column definitions as they appear in the axis. However, you can rotate the table by 90 degrees so that the rows in the axis form the columns of the table, and the columns in the axis form the rows of the table. The keyword which requests this type of table is rgrid:
tab axis_name rgrid [;options]
The axis:
l rating
n01Brand A;col(a)=134
n01Brand B;col(a)=135
n01Brand C;col(a)=136
n01Brand D;col(a)=137
side
col a00;Base;Excellent;Very Good;Satisfactory;Poor;Very poor
tabulated in the normal way with grid produces a table with brands as the columns and ratings as the rows. With rgrid it generates a table in which the ratings are the columns and the brands are the rows.
If there are no g and p statements in the lower section of the axis, the column headings are generated in automatic mode.
Any options defined with op= on the a or flt statement are applied to the table whether or not it is rotated. If you have op=12 (absolutes and column percentages) specified on the a/flt statement, and you want to use the same axis with grid and rgrid, you must specify the correct output options for the rgrid table if horizontal percentages and absolutes are required. For example:
a;dsp;op=12
tab rating grid
tab rating rgrid;op=01
See also
Grid tables