Cross-tabulation of 3 variables with display of percentages
tab3way rowvar colvar supercolvar [weight] [if exp] [in range] [, cellpct rowpct colpct allpct rowtot coltot scoltot alltot format(%fmt) {freq|nofreq} usemiss]
by varlist: may be used with tab3way to stratify tables. See help by.
fweights are allowed. See help weights.
Description
tab3way cross-tabulates 3 variables and displays any combination of cell frequencies, cell percents, row percents and column percents. "Missing" categories may be specified. tab3way optionally provides row, column and supercolumn totals by temporarily augmenting observations in the existing data set and making a new category (labelled "TOTAL") for each variable to accommodate these totals. tab3way is a front end for tabdisp, although not all of the latter's options are implemented here.
Options
freq|nofreq displays|does not display cell frequencies. freq is the default.
cellpct displays cell percentages. The denominator of the cell percentage is the total N over the entire table.
rowpct displays row percentages. The denominator for the row percentage is the total N over all categories of the supercolvar within a specific rowvar/colvar combination.
colpct displays column percentages. The denominator for the column percentage is the total N over all categories of the rowvar within a specific supercolvar/colvar combination.
allpct displays cell frequencies and cell, row and column percentages. Specifying none of cellpct, rowpct, colpct or allpct provides just frequencies (default).
rowtot displays row totals.
coltot displays column totals.
scoltot displays supercolumn totals.
alltot displays row, column and supercolumn totals.
usemiss shows missing values as a separate category, similar to tabulate.., missing. (missing is an option for tab3way insofar as it is passed to tabdisp, where it has a different role.)
format(%fmt) specifies the display format for presenting percentages in the table's cells (the frequencies, if specified, are always displayed as integers). The default is %8.2f, which gives 2 decimal places.
In addition, any of the following options allowed by tabdisp may be specified: center, missing, cellwidth(#), csepwidth(#), scsepwidth(#), stubwidth(#).
Examples
. use auto . egen price_cat = cut(price), group(4) . tab3way price_cat rep78 foreign, rowpct colp format(%5.3f) . egen weight_cat = cut(weight), group(2) . bysort weight_cat: tab3way price_cat rep78 foreign, allp allt usemiss
Author
Philip Ryan Department of Public Health University of Adelaide South Australia email: philip.ryan@adelaide.edu.au
Also see
On-line: help for tabdisp, table, tabulate