*! Version 2.0.0 NJC 5 February 2001 STB-60 dm67.1 * 1.0.0 NJC 26 March 1999 STB-49 dm67 program define nmissing version 6.0 syntax [varlist] [if] [in] [, Min(str) Obs ] tempvar touse mark `touse' `if' `in' tokenize `varlist' if "`min'" == "" { local min 1 } else if "`min'" == "all" { if "`obs'" == "" { qui count if `touse' local min = r(N) } else { local min : word count `varlist' } } else { * evaluate first; hence allow expressions, or _N local min = `min' capture confirm integer number `min' if _rc { di in r "min( ) invalid" exit 198 } } if "`obs'" == "" { local first = 1 while "`1'" != "" { qui count if missing(`1') & `touse' if r(N) >= `min' { if `first' { di local first = 0 } if _caller() == 6 { local name "`1'" } else local name = abbrev("`1'",8) di in g "`name'" _col(12) in y %6.0f r(N) } mac shift } } else { tempvar nmiss obs qui gen int `nmiss' = 0 label var `nmiss' "Number missing" while "`1'" != "" { qui replace `nmiss' = `nmiss' + missing(`1') mac shift } gen long `obs' = _n label var `obs' "Observations" qui count if `touse' & `nmiss' >= `min' if r(N) > 2999 { /* limit for -tabdisp- */ di in g _n "`r(N)' observations: too many to show" } else if r(N) { tabdisp `obs' if `touse' & `nmiss' >= `min', /* */ cellvar(`nmiss') stubwidth(14) } } end /* With -obs- option, it would be simpler to go list `nmiss' if `nmiss' >= `min' but it does not seem possible to do this without seeing an ugly temporary variable name. -list- could be emulated by -display-, at the price of a loop over observations. Using -tabdisp- seems better than either of these. */