Hi all,

I am trying to run a loop to merge 10 files names year_1, year_2, ...., year_10 all at once.
Each dataset has 4 variables - ID, grades, total_score, time (denoting year number 1, 2, ....,10). Variable ID is same for all datasets.

I am using

Code:
 local myfilelist : dir . files "*.dta"
use year_1  
foreach f of local myfilelist {
merge 1:1 ID using `f'
drop _merge
save merged, replace }
However, it is not working. There are no errors. The output data "merged" is same as year_1. What could be going wrong? Any help is much appreciated. Thank you.