Dear community,

I am a real newbie to both Stata and this forum so please be patient with me and my easy question. At least I hope it is an easy one :-). I have a dataset with a string variable (names of districts) and would like to generate a new variable with the ISO codes of these districts. I found out how to generate the variable for only one of the strings:

gen district_code=102 if locationlevel2=="KAMPALA"

So now I would need to extend this by a list somehow to have something like: gen district_code=[102, 314] if locationlevel2==["KAMPALA", "ABIM"] that generates district_code that is 102 for Kampala, 314 for Abim etc. but I cannot figure out the right syntax for that. I also tried smth like gen district_code=0 and then if locationlevel2=="KAMPALA" {district_code=102} but that didn't work either.

I hope this question is understandable and easy to answer and wanna thank you in advance for your help!

Best, Tabea