I am trying to import some excel files from the same directory and merge them into a single .dta file. However, the files in my local filelist are always unable to be found. This even applies to those codes that used to be working on my computer before.
My code is as following
Code:
local allfiles : dir "C:\Users\Win\Desktop\数据库\1997" files "*.xlsx" tempfile building save `building', emptyok clear foreach f of local allfiles { import excel using "`f'", firstrow clear gen filename = "`f'" append using `building' save `building', replace }
file altg0bc-01311997.xlsx not found
r(601);
Is this a problem of my codes or the problems of other applications?
Thank you so much for your help.
P.S.: I copied this code from another statalist forum post. I'm sorry that I cannot find the original post now. Many thanks to the contributors.
0 Response to File not found error when looping over files in a directory
Post a Comment