Announcement

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

  • Exporting Logistic Regression Outputs (OR and CI) to excel

    Hello Members,

    I am a new Stata user and now trying to export the logistic regression results (Odd ratio and Confidence Interval ) to excel.
    I used the commands as follow ;

    eststo: svy: logistic Y i.X1
    esttab using output.csv, ci

    However, it does not export OR and CI results, but coefficient results instead, I think.
    Could you pls help me how to export OR and CI results from Log regression to excel?

    Thanks in advance
    Moon Lu


  • #2
    You might have better luck with one of the other routines that export results. I like outreg2 but there are several others that work as well.
    Also, t if you select a table in Stata and choose copy table, you can paste the table into Excel and it will retain the columns.

    Comment


    • #3
      You may wish to delve into - putexcel - machinery.

      See the example below:

      Code:
      . putexcel set myodds
      
      . logistic foreign mpg price displacement
      
      Logistic regression                             Number of obs     =         74
                                                      LR chi2(3)        =      64.85
                                                      Prob > chi2       =     0.0000
      Log likelihood = -12.607544                     Pseudo R2         =     0.7200
      
      ------------------------------------------------------------------------------
           foreign | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               mpg |   .8670886   .1043487    -1.19   0.236     .6848992    1.097742
             price |   1.001347   .0005704     2.36   0.018     1.000229    1.002465
      displacement |    .902493   .0355496    -2.60   0.009     .8354388    .9749292
             _cons |   7873.026   48246.09     1.46   0.143     .0478584    1.30e+09
      ------------------------------------------------------------------------------
      Note: _cons estimates baseline odds.
      Note: 7 failures and 0 successes completely determined.
      
      . putexcel (A1) = etable
      file myodds.xlsx saved
      Check the presentation in Excel:

      Click image for larger version

Name:	myimage1.png
Views:	1
Size:	101.1 KB
ID:	1437344
      Hopefully that helps.
      Best regards,

      Marcos

      Comment


      • #4
        For exporting Stata ouput to MS Word, you can also use asdoc (SSC). Just add asdoc to the beginning of any Stata command, and it will export nicely formatted tables.

        Code:
        ssc install asdoc
        sysuse auto
        asdoc logistic foreign mpg price displacement
        Click image for larger version

Name:	Untitled.png
Views:	1
Size:	30.9 KB
ID:	1437350

        Last edited by Attaullah Shah; 03 Apr 2018, 09:14.
        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
          Does anyone have a solution when using svy? When I run this using taylor linerization it exports using the syntax below. But when I try to apply this to a dataset using bootstrapping for some reason the confidence intervals do not export to excel. The system generates the columns in excel but leaves the cells blank.


          estpost svy, subpop(peel):tab SED1, per cv ci obs
          estout using "K:\Health Services\Epidemiology\Health Status Data\STATA\Peel2015.xls", ///
          cells("obs b(label(percent)) lb ub se(label(CV))") ///
          label unstack transform(@ 1/@) title (Weekly Hours Sedentary Activity excludes reading, Peel) append

          estpost svy, subpop(peel):tab SED1, count format(%11.0fc)
          estout using "K:\Health Services\Epidemiology\Health Status Data\STATA\Peel2015.xls", ///
          cells("obs b(label(estimate))") label unstack append

          Thanks,
          Suzanne

          Comment


          • #6
            I was using this code:

            asdoc logistic depvar indvar1 indvar2

            The code is working but I am not getting the 95% Confidence Interval in the MS Word file.

            Thanks,
            Shoummo

            Comment


            • #7
              Shoummo Sen Gupta In response to requests for confidence intervals, I have added this option to asdoc and several others. The new version is available on my website with relevant details. After initial testing, I shall send it to SSC. You can access the details and installation instruction from here https://fintechprofessor.com/2018/12...ing-stars-etc/
              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
                Attaullah Shah Thank you for the lovely asdoc command. However, even after installing the patched version from your website I encounter an r3001 error (see attached screenshot). Are you able to advise on this error?

                Many thanks,
                Alexander
                Attached Files
                Many thanks,
                Alexander
                (Stata v14.2 IC for Mac)

                Comment


                • #9
                  Thanks for your feedback. I have corrected the error, please try the following

                  copy and paste the following three lines in Stata command window and press enter
                  Code:
                  net install uninstall_asdoc, from(http://fintechprofessor.com) replace
                  uninstall_asdoc
                  net intall asdoc, from(http://fintechprofessor.com) replace
                  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
                    Attaullah Shah Cheers for getting to this so quick. Table with 95%CI in the export is working. Last line of your code there is a typo: it should be install for those who don't know why they get an error copying and pasting this into the command window.

                    Happy New Year!

                    Many thanks,
                    Alexander

                    Originally posted by Attaullah Shah View Post
                    Thanks for your feedback. I have corrected the error, please try the following

                    copy and paste the following three lines in Stata command window and press enter
                    Code:
                    net install uninstall_asdoc, from(http://fintechprofessor.com) replace
                    uninstall_asdoc
                    net intall asdoc, from(http://fintechprofessor.com) replace
                    Many thanks,
                    Alexander
                    (Stata v14.2 IC for Mac)

                    Comment


                    • #11
                      Originally posted by Attaullah Shah View Post
                      Shoummo Sen Gupta In response to requests for confidence intervals, I have added this option to asdoc and several others. The new version is available on my website with relevant details. After initial testing, I shall send it to SSC. You can access the details and installation instruction from here https://fintechprofessor.com/2018/12...ing-stars-etc/
                      Thank you.. It is working.

                      Shoummo

                      Comment


                      • #12
                        I was using these commands,

                        asdoc logistic depvar indvar
                        asdoc logit depvar indvar,or

                        I got the desired result except the Odds Ratio in the MS Word file. The output is giving the coeffiecients instead of OR in the word file. Is there anything that I am missing in the command?

                        Thank you
                        Shoummo

                        Comment


                        • #13
                          Originally posted by Shoummo Sen Gupta View Post
                          I was using these commands,

                          asdoc logistic depvar indvar
                          asdoc logit depvar indvar,or

                          I got the desired result except the Odds Ratio in the MS Word file. The output is giving the coeffiecients instead of OR in the word file. Is there anything that I am missing in the command?

                          Thank you
                          Shoummo
                          I just noticed that it is giving the OR in the word file. The heading of the column is "Coef" instead of "OR"

                          Comment


                          • #14
                            Noted with thanks.
                            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
                              @Marcos Almeida

                              I tried your putexcel command, and this is the error I got.
                              Attached Files

                              Comment

                              Working...
                              X