Hello Statalist
I have 2 lists of datasets containing a personal identification number (not unique) and a record number (unique), among other variables differing for each of the lists. All the sets in the 2 lists are seperated by year, because the record number shifts each year. Therefore, I have to merge by record number for each year. Thus my code will look something like this:
use lpr_1993
sort recnum
merge m:m recnum using pop_1993
I was wondering if there was a form of "loop"-code that would enable me to run this command for each year? It's merely a question of saving space in the dofile, and time.
I have been looking into using the "foreach" command, but I'm quite new to this, so I'm not sure how it will work, or even if it is applicable in this scenario. I hope you can help me.
Mads
I have 2 lists of datasets containing a personal identification number (not unique) and a record number (unique), among other variables differing for each of the lists. All the sets in the 2 lists are seperated by year, because the record number shifts each year. Therefore, I have to merge by record number for each year. Thus my code will look something like this:
use lpr_1993
sort recnum
merge m:m recnum using pop_1993
I was wondering if there was a form of "loop"-code that would enable me to run this command for each year? It's merely a question of saving space in the dofile, and time.
I have been looking into using the "foreach" command, but I'm quite new to this, so I'm not sure how it will work, or even if it is applicable in this scenario. I hope you can help me.
Mads
Comment