Hi,
I have a string variable "city" of cities (London, Paris, Madrid). I want to destring it and create a code like that : London=1 ; Paris=2; Madrid=3 but i want to keep labels
Can we do that with 1 line of "destring"?
I know i can just do that :
replace city="1" if city=="London"
replace city="2" if city=="Paris"
replace city="3" if city=="Madrid"
destring city, replace
label define City 1 "London" 2 "Paris" 3 "Madrid"
label values city City
but is there not an easier and faster method?
Thanks !
I have a string variable "city" of cities (London, Paris, Madrid). I want to destring it and create a code like that : London=1 ; Paris=2; Madrid=3 but i want to keep labels
Can we do that with 1 line of "destring"?
I know i can just do that :
replace city="1" if city=="London"
replace city="2" if city=="Paris"
replace city="3" if city=="Madrid"
destring city, replace
label define City 1 "London" 2 "Paris" 3 "Madrid"
label values city City
but is there not an easier and faster method?
Thanks !
Comment