Hello,
I have a very large series of files (approx 200k) that I am trying append together (in a previous step I insheeted them from CSVs). To avoid the 'too many filenames' problem, I have now put them into folder organized by year. So I have files in folders named 1990, 1991....2023.
Now I want to append them together into annual files (before finally appending all the year files together).
My code to append right now is failing and I am not sure why. Here is the syntax:
When I run this, I get an error saying a specific file in the 1990 folder cannot be found. But on checking manually, the file is there.
And if I break out the first loop and display the results - ie just:
...it list the files fully, without error. So presumably the error is in the second nested loop. But not sure where.
Any thoughts on where I am going wrong?
Thanks!
I have a very large series of files (approx 200k) that I am trying append together (in a previous step I insheeted them from CSVs). To avoid the 'too many filenames' problem, I have now put them into folder organized by year. So I have files in folders named 1990, 1991....2023.
Now I want to append them together into annual files (before finally appending all the year files together).
My code to append right now is failing and I am not sure why. Here is the syntax:
Code:
foreach yr of numlist 1990/2023 { local files: dir `"xx/_data/`yr'"' files "*.dta" local dir1 "xx/_data/" qui display `"`files'"' foreach f of local files { append using `"`f'"', force drop if agglvl_code==17 | agglvl_code==57 } save `"`dir1'/`yr'_allplaces.dta"', replace, replace }
And if I break out the first loop and display the results - ie just:
Code:
foreach yr of numlist 1990/2023 { local files: dir `"xx/_data/`yr'"' files "*.dta" local dir1 "xx/_data/" display `"`files'"' }
Any thoughts on where I am going wrong?
Thanks!
Comment