Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tabout Into Different Sheets

    Hi,

    Somean can help me
    I wanto use tabout comand to export tables to excel. But I'd like to do it into differents sheets.

    I know that I can append a lot of tables in the same sheet, but export them to differents sheets it is difficult

    Thank
    Paul

  • #2
    Hi Paul,

    I would recommend looking into -putexcel-, which is a command in Stata 13 which allows you to export tables fairly easily (and which will allow you to specify which sheet of a workbook you would like to export to). There's a good introduction to -putexcel- here: http://blog.stata.com/2013/09/25/exp...bles-to-excel/

    I've found -putexcel- to be a bit more versatile than -tabout-, so I highly recommend it.

    Thanks!
    Isaac



    Comment


    • #3
      Beyond -putexcel- , I like using -import excel- in a loop for this purpose.

      Here's a quick example:

      Code:
      sysuse auto, clear
      
        cap rm `"myfile.xlsx"' //get rid of main excel file
      
      
      *create 5 tabout tables
      
      foreach v in mpg turn head trunk rep78 {
      tabout `v' foreign using `"example_`v'.xls"', ///
          replace c(freq col) clab(n col%) ptotal(both) ///
          h1(`:var lab `v'') f(1c 1p) mi
      }
      
      **insheet them and then save to excel in sheets:
      foreach v in mpg turn head trunk rep78 {
      preserve
        insheet using `"example_`v'.xls"', clear nonames
        export excel using `"myfile.xlsx"', sheetreplace sheet("`v'")
        rm `"example_`v'.xls"'  //get rid of extra files
      restore
      }
      
      **check:
      import excel using `"myfile.xlsx"', describe
      Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

      Comment


      • #4
        Thanks .....
        It helped me a lot

        Comment


        • #5
          eric_a_booth was trying to use your Idia but face this problem , I have created a tabulation using tabout into excel, and now I want to import it back to Stata using import excel command, but I get this error message "error: "the central directory is not found in the archive (or you were trying to open not the last volume of segmented archive)."

          Comment

          Working...
          X