I would like to import many files (about 200) using Stata's inline dictionary function (as the data is .txt fixed width). This is working for me with any one file, but I can't seem to do it with a loop over all the files. (The name of my dictionary here is fed_emp_dict_1)
I have:
local dir "/~/"
local data : dir "`dir'" files "*.txt"
foreach f of local data
{
infile using fed_emp_dict_1, using("`f'")
save "`f'".dta, replace
}
The goal is to append all the files into one dataset (that's been fixed with the specifications of the dictionary).
For this I was trying:
foreach f of local data {
append using "`f'"
save d:data_merge_1.dta, replace
}
Stata isn't giving me any errors, but the files aren't being replaced, nor is the composite merge file being created. Please advise.
infilecommand". - Nick Cox{must be on the same line asforeach. - Nick Cox