program define nbmiss
version 8.0
syntax varlist(min=1) [, nbmiss(string)]

if "`nbmiss'"=="" {
local nbmiss nbmiss
}

local nbitems:word count `varlist'
tokenize `varlist'

qui gen `nbmiss'=0

forvalues i=1/`nbitems' {
qui replace `nbmiss'=`nbmiss'+1 if ``i''==.
}
end