[P] _nobs -- Programmer's utility for counting the number of observations
_nobs varname [weight] [if exp] [in range] [, min(#) zeroweight ]
fweights, aweights, iweights, and pweights are allowed; see weights.
_nobs counts the number of observations based on a 0/1 variable giving
the sample. (Strictly speaking, the variable is evaluated as 0/not 0.)
It is an rclass command, and the number of observations are returned in
If frequency weights (fweights) are specified, then the sum of the
weights is used for the number of observations. If the weights are any
other type, they are marked out, but otherwise ignored.
If the number of observations is less than those specified by the min()
option, an appropriate error message is issued.
min(#) specifies the minimum allowed number of observations. If the
number of observations is less than #, an error message is displayed.
The default is min(1).
zeroweight specifies that weights of zero are not to be marked out.
_nobs is intended for use by programmers. Its typical use is the
program define myprog
syntax [varlist] [fweight iweight] [if] [in]
_nobs `touse' [`weight'`exp'], min(2)
local N = r(N)