asdocx: Export from Stata to Word, Excel, LaTeX & HTML Forums asdocx Forum Looping through datasets in folder

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Natalie Daya
    Post count: 1


    How would you loop through “.dta” files in a given location and run asdocx codebook?

    Thank you,

    Attaullah Shah
    Post count: 70

    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)
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.