I have a county field that was a string and has been encoded, creating a value label of the same name.
If I want to get the name of county 3, I can just use local foo : label county 3.
But how can I programmatically get the number corresponding to a string?
So for example:
label define county 1 "Wade" 2 "Higgs" 3 "Leon"
lab val county county
I want to be able to get 3 from the string "Leon". I know I used to know how to do this (something like county["Leon"], if I recall correctly, slash am not just imagining the whole thing), but I can't seem to find any documentation. Obviously I can use -levels- to get all the numerics, and then loop through them, but I'm looking for a more direct syntax, as there are a lot of counties.
Thanks!
If I want to get the name of county 3, I can just use local foo : label county 3.
But how can I programmatically get the number corresponding to a string?
So for example:
label define county 1 "Wade" 2 "Higgs" 3 "Leon"
lab val county county
I want to be able to get 3 from the string "Leon". I know I used to know how to do this (something like county["Leon"], if I recall correctly, slash am not just imagining the whole thing), but I can't seem to find any documentation. Obviously I can use -levels- to get all the numerics, and then loop through them, but I'm looking for a more direct syntax, as there are a lot of counties.
Thanks!
Comment