__Title__

**[P] _nobs** -- Programmer's utility for counting the number of observations

__Syntax__

**_nobs** *varname* [*weight*] [**if** *exp*] [**in** *range*] [**,** **min(***#***)** __zero__**weight** ]

**fweight**s, **aweight**s, **iweight**s, and **pweight**s are allowed; see weights.

__Description__

**_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
**r(N)**.

If frequency weights (**fweight**s) 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.

__Options__

**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.

__Example__

**_nobs** is intended for use by programmers. Its typical use is the
following:

**program define myprog**
**version** *...*
**syntax [varlist] [fweight iweight] [if] [in]**
**marksample touse**

**_nobs `touse' [`weight'`exp'], min(2)**

**local N = r(N)**

*...*
**end**