Hi all,
My data include 50 countries. Sometimes I need to change some values in
another variable based on country name. If I leave country names as string,
the following does not work, for example.
replace revenue=100 if country==Australia
So, I usually change country names into numeric using "encode."
label list country
1 Argentina
2 Aruba
3 Australia
4 Austria
5 Bahrain
.......
Then, I use the following code:
replace revenue=100 if country==3
However, if I drop or add some contries later Australia is no longer 3 and I
have to go through my do file to correct every possible mistake which is
frustrating. Is there any better way to do this job so that I can reduce
errors in data management?
Thank you in advance.
Mike.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/