mvdecode
is for numeric variables only: the banner in the help is "Change numeric values to missing values" (emphasis added). So the error message should make sense: the string "missing"
is certainly not a numeric value, so Stata stops you there. It makes no sense to say to Stata that numeric values "missing"
should be changed to system missing, as you requested.
As for what you should do, that depends on what you mean in Stata terms by coded "missing"
.
If you are referring to string variables with literal values "missing"
which should just be replaced by the empty string ""
, then that would be a loop over all string variables:
ds, has(type string)
quietly foreach v in `r(varlist)' {
replace `v' = "" if `v' == "missing"
}
If you are referring to numeric variables for which there is a value label "missing"
then you need to find out the corresponding numeric value and use that in your call to mvdecode
. Use label list
to look up the asssociation between values and value labels.