[email protected]
>
> DHS are the Macro-International databases on Demographic
> and Health Surveys.
> Many variables in these datasets contains missings
> observations and are
> labelled with NA: I mean:
> e.g:
> - v224 "Child receives juice, NA"
> -tab v224
> . no observation
>
> I want to know how to drop these variables.
If a variable label ending in "NA" means that
the variable is of no use, then you
can use -ds3- from SSC to drop such variables.
ds3, has(varl *NA)
drop `r(varlist)'
Alternatively, here is the route from first
principles.
foreach v of var * {
local label : variable label `v'
if substr(`"`label'"',-2,2) == "NA" {
drop `v'
}
}
On the other hand, if the diagnostic is
just no non-missing values, then use
-dropmiss- as previously mentioned, or
foreach v of var * {
capture assert missing(`v')
if _rc == 0 {
drop `v'
}
}
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/