Announcement

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

  • Copying Output from STATA to Word docs

    Hi, I want to copy the output from Stata (as picture) and paste it into Word as picture, but when I do this, the file gets too large whenever I want to send it. I didn’t want to use log and save as pdf as it is only certain parts of the output I want sent, not the entire thing. And sometimes I make mistakes in the command so error messages come up and I don’t want to save that either. Any suggestions please? I read about the putdocx and collect command but I am not sure how to use it. Thank you.

  • #2
    If you insist on copying as pictures, there's no room flexibility beyond using some image editing software to crop and compress it. Even if you crop it in Word, the original image with all its pixel detail is retained in the file and can be reset to it's original.

    On a broader note, there should be no harm in sharing properly formatted tables, or even log output as text, with whomever. If you need to edit something sensitive out, delete the text later. Either way, you would do well to spend some time to learn how to use -putdocx-, -putexcel- or -putpdf- and expand from there to other built in and user contributed comands as needed.

    Comment


    • #3
      copying/pasting is rarely a good way. If selectively logging is all you need, then you can use log on and log off to log the parts you would like to share. For example

      Code:
      log using test.log, text replace nomsg
      * logged
      regress mpg price
      log off
      
      * not logged
      logit foreign rep78 price
      
      log on
      * logged
      logit foreign  price mpg
      
      log off
      log close
      If you would like to put the out in a docx file with some explanation text in between, you may consider using putdocx textfile to automate the process. Here is an example:

      Code:
      sysuse auto, clear
      
      putdocx begin
      
      putdocx paragraph
      putdocx text ("We show how to use putdocx textfile to put several Stata logs into a docx file.")
      
      log using test.log, text replace nomsg
      regress mpg price
      log close
      
      * now we put test.log to test.docx
      putdocx textfile test.log, stopat(". log close")
      
      * not logged
      logit foreign rep78 price
      
      putdocx paragraph
      putdocx text ("We add another log file to docx, in this example, we simply reuse test.log.")
      
      
      log using test.log, text replace nomsg
      logit foreign price mpg
      log close
      
      putdocx textfile test.log, stopat(". log close")
      
      putdocx save test.docx, replace
      A dynamic document using dyndoc also can be used to archive the effect with even more flexibility. If you are interested, I will put up an example later.
      Last edited by Hua Peng (StataCorp); 26 Oct 2021, 08:16.

      Comment


      • #4
        asdoc (available from SSC) works with almost every Stata command and produces output that closely matches the one shown on Stata screen. Once exported to MS Word, you can edit the document in anyway you wish. See this example.
        Code:
        ssc install asdoc
        sysuse auto, clear
        asdoc sum
        asdoc cor
        asdoc reg price mpg trunk weight
        Attached Files
        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


        • #5
          Professor Attaullah, that is amazing! Thank you. I appreciate your advice. Lena

          Comment


          • #6
            Professor Attaullah, how can I recode to show 3-decimal points on the p-value in the table 0.000 instead of just 0? Thank you.

            Comment


            • #7
              Try using tzok option.
              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


              • #8
                I am wondering how the asdoc works with exporting the marginal effects (MEs) of a probit regression and to export the mean of covariates used in this regression

                Comment


                • #9
                  Can you please provide an example code?
                  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


                  • #10
                    Thanks for your response! I am providing a minimal example here

                    Code:
                    probit claim  amt age age2 married  i.year [pw=hweight] if head==1, robust
                    margins, dydx(*) atmeans post
                    est store mod1

                    Comment


                    • #11
                      Adding margins to asdoc seems to require quite some efforts. At the moment, it was easy to add it to asdocx. Therefore, I added it to asdocx. Here is a working example of reporting margins with asdocx. https://fintechprofessor.com/asdocx/...s-with-asdocx/
                      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


                      • #12
                        Thanks a lot! I will look into asdocx since I never used it before.

                        Comment

                        Working...
                        X