I often use the long neglected -matrix- facility of regular (non-Mata) Stata to recode small intergers:
which runs at about 5 million observations per second independent of the number of possible values. Once a recode involves states of the US (51 values) or countries in the world (>200 values) that can be important. -Recode- appears to be dominated by -if-then-else- both for speed, generality and simplicity of learning and remembering.
Code:
matrix input agerangemin =(20,35,45,55,65,75) gen agemin=agerangemin[1,agerange]
Comment