You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
510 B
Plaintext
24 lines
510 B
Plaintext
9 months ago
|
program define dropmissing
|
||
|
syntax varlist [, missing(string) delete]
|
||
|
|
||
|
tokenize `varlist'
|
||
|
local nbitems:word count `varlist'
|
||
|
if "`missing'"=="" {
|
||
|
local missing="."
|
||
|
}
|
||
|
|
||
|
local nbmissing:word count `missing'
|
||
|
|
||
|
forvalues i=1/`nbitems' {
|
||
|
forvalues j=1/`nbmissing' {
|
||
|
local miss:word `j' of `missing'
|
||
|
if "`delete'"!="" {
|
||
|
drop if ``i''==`miss'
|
||
|
}
|
||
|
else {
|
||
|
replace ``i'=. if ``i''==`miss'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
end
|