Hello Statalist,
I have 234 .txt files in a folder that I have written a loop to import and save as stata files. I would like to modify the code to delete the .txt files after import but am having trouble getting the code to work. What I have thus far is:
That codes does its job quite well but I am unclear on what modifications to make to it to get it to delete the .txt files.
Any help would be greatly appreciated.
Best,
Joseph
I have 234 .txt files in a folder that I have written a loop to import and save as stata files. I would like to modify the code to delete the .txt files after import but am having trouble getting the code to work. What I have thus far is:
Code:
clear cd "Z:\Data - Copy\DEED (transactions)\Import Test" local myfilelist : dir . files "*.txt" foreach x of local myfilelist { import delimited using `x', delimiters("|") case(preserve) local x = subinstr("`x'",".txt","",.) save "`x'", replace clear }
Any help would be greatly appreciated.
Best,
Joseph
Comment