-------------------------------------------------------------------------------
help for tabcond
-------------------------------------------------------------------------------

Tabulate frequencies satisfying specified conditions

tabcond groups varname [if exp] [in range] [weight] , cond(condition_list) [ listwise tabdisp_options ]

tabcond variables varlist [if exp] [in range] [weight] , cond(condition_list) [ listwise tabdisp_options ]

by ... : may be used with tabcond; see by. fweights, aweights, and iweights are allowed; see weights.

Description

tabcond tabulates frequencies satisfying up to 5 specified conditions. Zero frequencies are shown explicitly.

There are two syntaxes. With tabcond groups, the rows of the table show the distinct groups of varname and the columns show the frequencies of observations satisfying specified conditions. With tabcond variables, the rows of the table show the variables specified and the columns show the frequencies of observations satisfying specified conditions: the conditions must each include a wildcard @ for which is substituted in turn each variable name.

Options

cond(condition_list) specifies a list of true or false conditions, for which the frequencies (zero or more) of observations satisfying those conditions are to be shown. Unless they can expressed without embedded spaces, conditions must be bound in double quotes " " and if necessary compound double quotes `" "'. This is a required option.

listwise specifies that frequencies should be determined for as many observations as possible. By default casewise deletion on varlist is used to ensure consistency in observations selected.

tabdisp_options are options of tabdisp, which may be used to tune the appearance of the table.

Examples

. tabcond g rep78, c("mpg > 30" "mpg <= 30" "weight > 3000")

. tabcond g rep78, c(mpg>30 mpg<=30 weight>3000)

The two commands above have the same result, except that conditions are echoed exactly as typed as column headings.

. bysort foreign: tabcond g rep78, c("mpg > 30" "mpg <= 30")

. tabcond v price-foreign, c("@ < 0")

. tabcond v *, c(missing(@)) listwise

Author

Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

Acknowledgements

Kit Baum made many useful comments on this problem.