Dear All,
I have a dataset contains Country variable, with country names as string values. I've been trying to generate a region variable, here's what I tried:
I'm wondering if there's are easier way, say generate Region = "South America" if Country is inlist(Argentina, Brazil, Peru...), so that I don't have to type "Country ==" part many times?
Any help is appreciated!
Thank you!
Best,
Craig
I have a dataset contains Country variable, with country names as string values. I've been trying to generate a region variable, here's what I tried:
Code:
gen Region = " "
Code:
bysort Country Year: replace Region = "South America" if Country == "Argentina" | Country == "Brazil" | Country == "Peru"...
Any help is appreciated!
Thank you!
Best,
Craig
Comment