Dear all,

I am trying to merge multiple dataset. The names of the dataset are "1.mammor.dta", "2.pappor.dta", "3.barn.dta", and "4.syskon.dta". The key (ID) variable is lopnr. Initially, I tried with following codes
Code:
global workdir "D:\Umea Phd\2)Project 2\Survival_working\SoS\28421_2020_Lev\STATA files\"

use "${workdir}1.mammor.dta",clear
sort lopnr
merge 1:1 lopnr using "${workdir}2.pappor.dta", nogenerate
merge 1:1 lopnr using "${workdir}3.barn.dta", nogenerate
merge 1:1 lopnr using "${workdir}4.syskon.dta", nogenerate
The above codes is ok to merge. For multiple dataset, I would like to use looping and tried the following codes,

Code:
global workdir "D:\Umea Phd\2)Project 2\Survival_working\SoS\28421_2020_Lev\STATA files\"

use "${workdir}1.mammor.dta",clear
foreach file in 2.pappor.dta 3.barn.dta 4.syskon.dta {
sort lopnr
merge 1:1 lopnr using "${workdir}`file'", nogenerate    
}
But the error message appeared as
file D:\Umea Phd\2)Project 2\Survival_working\SoS\28421_2020_Lev\STATA files.dta not found
r(601);
I have checked the file direction and file names, and they are correct. Please kindly help me how I can solve this problem.

Kind regards,
Moon Lu