asdocx: Export from Stata to Word, Excel, LaTeX & HTML › Forums › asdocx Forum › Looping through datasets in folder › Reply To: Looping through datasets in folder
Let’s assume that you have a folder named temp in drive c and you have several .dta files in it. You wish to create a codebook from all the .dta files and save them to codebook.docx file. The following code will do the job.
local files : dir "c:/temp" files "*.dta" cd c:/temp foreach file in `files' { use `file' , clear asdocx codebook , save(codebooks.docx) }