Hi,
I have a large number of numeric variables (about 3-400) where I want to replace certain values with missing, and I use this loop:
quietly ds, has(type numeric)
foreach var of varlist `r(varlist)' {
display "Replacing missing in `var'"
list `var' if inlist(`var',99,999,888,-9)
replace `var' = . if inlist(`var',99,999,888,-9)
}
But for a few of these numeric variables, I don't want to replace these values, for example record_id, where 99 and 888 are valid id's.
Is it possible to remove som of the variables generated in ds? Or some other smart solution?
My only idea is to temporarily convert them to strings, but that's not so elegant :-)
Thanks, Anna
I have a large number of numeric variables (about 3-400) where I want to replace certain values with missing, and I use this loop:
quietly ds, has(type numeric)
foreach var of varlist `r(varlist)' {
display "Replacing missing in `var'"
list `var' if inlist(`var',99,999,888,-9)
replace `var' = . if inlist(`var',99,999,888,-9)
}
But for a few of these numeric variables, I don't want to replace these values, for example record_id, where 99 and 888 are valid id's.
Is it possible to remove som of the variables generated in ds? Or some other smart solution?
My only idea is to temporarily convert them to strings, but that's not so elegant :-)
Thanks, Anna
Comment