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 }
0 Response to Loop to merge multiple dta files
Post a Comment