{smcl}
{* 5 November 2002}{...}
{hline}
help for {hi:tabcond}
{hline}

{title:Tabulate frequencies satisfying specified conditions}

{p 2 11}
{cmd:tabcond}
{cmdab:g:roups} 
{it:varname} 
[{cmd:if} {it:exp}] 
[{cmd:in} {it:range}] 
[{it:weight}] 
{cmd:,}
{cmdab:c:ond(}{it:condition_list}{cmd:)}
[
{cmd:listwise} 
{it:tabdisp_options}
]

{p 2 11}
{cmd:tabcond}
{cmdab:v:ariables}
{it:varlist} 
[{cmd:if} {it:exp}] 
[{cmd:in} {it:range}] 
[{it:weight}] 
{cmd:,}
{cmdab:c:ond(}{it:condition_list}{cmd:)}
[
{cmd:listwise} 
{it:tabdisp_options}
] 

{p}{cmd:by ... :} may be used with {cmd:tabcond}; see {help  by}.  
{cmd:fweight}s, {cmd:aweight}s, and {cmd:iweight}s are allowed;
see {help weights}.
 

{title:Description}

{p}{cmd:tabcond} tabulates frequencies satisfying up to 5 specified 
conditions. Zero frequencies are shown explicitly. 

{p}There are two syntaxes. With {cmd:tabcond groups}, the 
rows of the table show the distinct groups of {it:varname} 
and the columns show the frequencies of observations 
satisfying specified conditions. With {cmd: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 {cmd:@} for which is substituted in turn each variable 
name.  


{title:Options}

{p 0 4}{cmd:cond(}{it:condition_list}{cmd:)} 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 {cmd:" "} and if necessary
compound double quotes {cmd:`" "'}. This is a required option. 
 
{p 0 4}{cmd:listwise} specifies that frequencies 
should be determined for as many observations as possible. 
By default casewise deletion on {it:varlist} is used to ensure 
consistency in observations selected.  

{p 0 4}{it:tabdisp_options} are options of {help tabdisp}, which 
may be used to tune the appearance of the table. 

{title:Examples}

{p 4 8}{inp:. tabcond g rep78, c("mpg > 30" "mpg <= 30" "weight > 3000")}

{p 4 8}{inp:. tabcond g rep78, c(mpg>30 mpg<=30 weight>3000)}

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

{p 4 8}{inp:. bysort foreign: tabcond g rep78, c("mpg > 30" "mpg <= 30")}

{p 4 8}{inp:. tabcond v price-foreign, c("@ < 0")} 

{p 4 8}{inp:. tabcond v *, c(missing(@)) listwise}


{title:Author} 

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


{title:Acknowledgements} 

	Kit Baum made many useful comments on this problem. 

