Announcement

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

  • Transfering tables created in Stata to Word

    Hi Guys!,
    Is it possible to programmatically transfer all kinds of tables and graphs into Word? These tables are Summary and Descriptive Stats tables, Panel regression tables etc. If so, what are the list of possible commands? When I copy my tables into my Word documents, the format is destroyed. Thanks for your help.

    Tony

  • #2
    If your demands are simple, I mean, you just want to get a table of the results, you may copy the output from Stata and paste it in Word. Then, you may select the font Courier New, size 8. Usually, it will do the trick.

    On the other hand, shall you wish more complex tables, there are several user-written programs about that.

    In Stata 15, by the way, you have the command - putdocx - for this task.
    Best regards,

    Marcos

    Comment


    • #3
      Thank, Marcos!
      I like the second option, putdocx. I have been able to transfer a regression table into Word using putdocx. Very helpful. However, I tried doing the same for panel data descriptive stats tables and have failed. There may be commands for specific tables I am missing. For example, to transfer my regression table to Word, I saved the table using "estimates" i.e. estimates store tableName. So the table was stored as tableName, which I grabbed into Word.What commands do I use to replace the "estimates" for other forms of tables? Where do I find a list these commands for various tables and graphs?

      Comment


      • #4
        Hello, Tony.


        You may wish to take a look at this text, particularly from the example 2 onwards. Hopefully it will be helpful to you.
        Best regards,

        Marcos

        Comment


        • #5
          Wasn't too help. I had already done the estimates one, but the descriptive stats on did not work.

          Comment


          • #6
            In Stata 15, you can ssc install corr2docx, sum2docx, and reg2docx, respectively, and see their help file for further instruction.
            Ho-Chuan (River) Huang
            Stata 17.0, MP(4)

            Comment


            • #7
              Tony Annan
              Wasn't too help. I had already done the estimates one, but the descriptive stats on did not work.
              I gather you didn't take a closer look at the examples shared in #4.

              If by "descriptive stats" you meant, say, the N, mean, SD, min and max values, surely you can get a table to export in Word.

              Below, I share an example. Just to make it a litte bit complex, I decided to present "descriptive stats" (of mpg) BY 2 variables (foreign and rep78). Let's also left-align the first column, and the remaining ones we will leave centered. On second thoughts, we could well get rid of borders. On top of that, we may rename the variables. To end - why not - the title in bold:

              Code:
              webuse auto, clear
              preserve
              putdocx begin
              statsby Total=r(N) Average=r(mean) SD=r(sd) Max=r(max) Min=r(min), by(foreign rep78): summarize mpg
              rename rep78 Repair_Record_1978
              rename foreign Origin
              putdocx table tbl1 = data("Origin Repair_Record_1978 Total Average SD Max Min"), varnames border(all, nil)
              putdocx table tbl1(1,.), bold
              putdocx table tbl1(.,1), halign(left)
              putdocx table tbl1(.,2), halign(center)
              putdocx table tbl1(.,3), halign(center)
              putdocx table tbl1(.,4), halign(center)
              putdocx table tbl1(.,5), halign(center)
              putdocx save mydoc1, replace
              Below, a view of the Word file.
              Click image for larger version

Name:	Image - putdocx.png
Views:	1
Size:	39.9 KB
ID:	1410705




              Hopefully that helps!
              Last edited by Marcos Almeida; 16 Sep 2017, 13:56.
              Best regards,

              Marcos

              Comment


              • #8
                Thank you so much, Marcos. This helps! I had conditioned my mindset that there should be a one-line code that can grab the table into Word. The list of codes you've shown here should equally work. Thanks. Tony

                Comment


                • #9
                  A follow-up question though. My data is an unbalanced panel data with 26 variables and the cases changing by id and years. Since panel analysis uses different summary than cross-section data, how do I change the above code to produce a descriptive panel table in Word? Tony

                  Comment


                  • #10
                    You will basically deal with - return - information. Provided you have it, the process is the same.
                    Best regards,

                    Marcos

                    Comment


                    • #11
                      River Huang, those corr2docx, sum2docx, and reg2docx commands worked perfect. Thanks. Would you know how I can adapt them to panel data analysis like xttab, tabulate, xtdescribe and tabstat?

                      Comment


                      • #12
                        Originally posted by Tony Annan View Post
                        River Huang, those corr2docx, sum2docx, and reg2docx commands worked perfect. Thanks. Would you know how I can adapt them to panel data analysis like xttab, tabulate, xtdescribe and tabstat?
                        I am not quite sure but you might want to check out (search first, and then install) outreg2, esttab, and tabout, respectively.
                        Ho-Chuan (River) Huang
                        Stata 17.0, MP(4)

                        Comment


                        • #13
                          Do you know if sum2docx has an option that allows reporting missing values along with the descriptives?

                          Comment


                          • #14
                            You can install asdoc from SSC.
                            Code:
                            ssc install asdoc
                            asdoc works virtually with all Stata commands and sends the output in form of nicely formatted tables. See this simple example on my web page
                            https://fintechprofessor.com/2018/02...basic-example/

                            You can also read the posting entry on Statalist here
                            Regards
                            --------------------------------------------------
                            Attaullah Shah, PhD.
                            Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                            FinTechProfessor.com
                            https://asdocx.com
                            Check out my asdoc program, which sends outputs to MS Word.
                            For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                            Comment


                            • #15
                              Dear all, Thank you very much!! I have learned a lot from your daily posts.
                              cheers , Hassen

                              Comment

                              Working...
                              X