Dear Statalisters,
I have a quick question about how to speed up the merging process.
Suppose I have one A dataset and several B dataset, denoted as B1, B2, B3, etc.
In A dataset, I have individuals' id numbers along with his/her birth
city and birth year. Now in B's datasets, it stores the information of
all the cities in a particular year, such as B1: all the cities for
year 1, B2: all the cities for year2, B3 for year3, etc. For example,
in year 1, I can get every city's population size for that year.
Now my goal is to get each individual's birth city population size, of
course, for that particular year when the individual was born. To
summarize, in dataset A, I have the following variables:
id birthyear birthcity
in B's datasets, I have
cityid population
I am aware that I should merge the right B dataset with A through
city, however, which year when the individual was born determines
which B dataset I should merge for that observation. I didn't find by:
or if... conditional command for "merge", as I imagined.
Is there a quickest way to finish this mission?
Thanks all.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/