Numbers of missing (present) values
nmissing [varlist] [if exp] [in range] [, min(#) obs piasm trim ]
npresent [varlist] [if exp] [in range] [, min(#) obs piasm trim ]
by ...: may be used with nmissing and npresent; see help by.
Description
nmissing lists the number of missing values in each variable in varlist (or optionally in each observation). Missing means numeric missing (that is, sysmiss . or one of the extended missing values .a to .z) for numeric variables and empty or "" for string variables. See help on missing for further information.
npresent lists the number of present (non-missing) values in each variable in varlist (or optionally in each observation).
Options
min(#) specifies that only numbers at least # should be listed. Default 1. The argument may be zero or any positive integer or any expression evaluating to zero or a positive integer. As a special case, _all or * means the number of variables in varlist or, with obs, all the observations specified.
obs specifies that counting is for observations, not variables.
piasm specifies that period is also string missing: that is, "." counts as missing. Some Stata users use "." to indicate missing.
trim specifies that whether string values are missing is to be determined after trimming leading and trailing spaces. For example, with trim " " (a single blank) would count as missing.
trim piasm would specify that e.g. " . " counts as missing.
Saved results
If the obs option is not used, r(varlist) holds the list of variables containing more than min() missing values. If the obs option is used, r(varlist) just echoes varlist.
Examples
. nmissing
. nmissing rep78
To see which observations have all missing values:
. nmissing, min(*) obs
To get details on variables with 10 or more missing values:
. nmissing, min(10) . d `r(varlist)'
. npresent
Author
Nicholas J. Cox, Durham University, U.K. n.j.cox@durham.ac.uk
Acknowledgements
A question by Eric Uslaner led to the addition of r(varlist) as a saved result.
Also see
Online: help for missing; dropmiss (if installed)