Hello Statalist,
My goal is to compile multiple .dta files that all live in the same directory (and are the only files in that directory) into a single Excel workbook with one tab/sheet per .dta file.
The files all end in either 2010_2019.dta or 2012_2019.dta.
I'm having two issues:
This returns "end of do-file", but does not produce the spreadsheets. The -display command also returns nothing -- appears to be empty (issue 1 above).
Also, I realize that the above code, if working properly, would export individual excel spreadsheets for each .dta -- any advice on how to adjust to address issue 2 above?
Thanks very much!
Ian
My goal is to compile multiple .dta files that all live in the same directory (and are the only files in that directory) into a single Excel workbook with one tab/sheet per .dta file.
The files all end in either 2010_2019.dta or 2012_2019.dta.
I'm having two issues:
- the local I am using does not appear to be storing the file information for the .dta files
- I can't figure out the code for the export to Excel part
Code:
cd "C:\Users\ianbg\Desktop\LTR\STATA\Community Profiles\Community Profiles Calculations\2019 Calculations\datasets" local files : dir . files `" *2010_2019 *2012_2019 "' di `files' foreach file of local files { use `file', clear export excel using `file', firstrow(varlabels) replace }
Also, I realize that the above code, if working properly, would export individual excel spreadsheets for each .dta -- any advice on how to adjust to address issue 2 above?
Thanks very much!
Ian
Comment