I am doing data clean-up in Stata and I need to recode a variable to equal 1 if a whole set of other variables are equal to 1, 6, or 7.
I can do this by writing out:
replace anyadl=1 if diffdress==1 | diffdress==6 | diffdress==7 | ///
diffwalk==1 | diffwalk==6 | diffwalk==7 | ///
diffbath==1 | diffbath==6 | diffbath==7 | ///
diffeat==1 | diffeat==6 | diffeat==7 | ///
diffbed==1 | diffbed==6 | diffbed==7 | ///
difftoi==1 | difftoi==6 | difftoi==7
However, this is very inefficient to type out and it's easy to make errors. Is there a simpler way to do this -- say, something like:
replace anyadl=1 if diff*==(1 | 6 | 7)
?
Thank you for any help you can provide!
Aucun commentaire:
Enregistrer un commentaire