Announcement

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

  • Exporting table to excel

    estimates table pre_crisis pre_crisis1 pre_crisis2 crisis crisis1 crisis2 post_crisis post_crisis1 post_crisis2, star stats(N r2 r2_a)

    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    Variable | pre_crisis pre_crisis1 pre_crisis2 crisis crisis1 crisis2 post_crisis post_crisis1 post_crisis2
    -------------+------------------------------------------------------------------------------------------------------------------------------------------------
    MAIV1 | -.12269193*** -.02313984 .11439476 -.02457669 .05733898*** .06337533***
    avgEPU | .0354143*** .01839623* -.05305954* -.0255495* .0059357** .00706056**
    _cons | -.43343095 .69192251 -1.596856* .39196367 -1.6256209* .47450906 -1.4818256** -.69119917* -.49930927
    -------------+------------------------------------------------------------------------------------------------------------------------------------------------
    N | 586 602 586 208 212 208 1443 1447 1443
    r2 | .04215311 .00140648 .01601135 .03944581 .0019522 .0230186 .01564897 .01075987 .0070858
    r2_a | .03886719 -.00025784 .01432644 .03007455 -.00280041 .01827598 .01428181 .01007527 .00639675
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    legend: * p<0.05; ** p<0.01; *** p<0.001


    Hi!

    I tried to use the command:

    outreg2 using file_name, excel

    When I open the document, only the forst column pops out in excel, and the variable MAIV1 is missing...
    (1)
    VARIABLES ln_ret100
    avgEPU 0.00706***
    (0.00170)
    Constant -0.499*
    (0.261)
    Observations 1,443
    Number of country1 12
    R-squared 0.007
    Robust standard errors in parentheses
    *** p<0.01, ** p<0.05, * p<0.1
    I can see from my table that stata is using pre_crisis pre_crisis1...etc as dependent variable, how do I correct for this, so that dependent variable is ln_ret100?

    Can anyone explain what Im doing wrong here, and what comand I should use?

    Thanks in advance!
    Last edited by Marius Helseth; 22 May 2019, 08:09.

  • #2
    I suspect it has to do with whether (a) you called the outreg2 command after each regression, or (b) using "append" or "replace" at the end of them (see below)

    Code:
    * Here is a few lines from a recent do file that uses outreg2
    * I usually define rhsvars, outreg_file, log_file, and do_file as local macros storing the right-hand side variables or files names
    * This just allows me to later call them as `log_file'.  Also makes it easy to re-use across different do files
    * local outreg_line1 "excel bdec(4) rdec(3) se bracket addstat(F test: , e(F)) adec(3)" 
    
    reg DV `rhsvars' if good==1, cluster(acq_gvkey)
    outreg2 using `outreg_file', `outreg_line1' ctitle("Everything - so lines up") ///
        addnote("", do file is `do_file', "Run on $S_DATE", Log file is `log_file', Using data from $S_FN) replace
       * Note $S_FN could also be written as c(filename) and $S_DATE could be written as c(current_date)
    
    reg   car4_250_100 `rhsvars' if good==1, cluster(acq_gvkey)
    outreg2 using `outreg_file', `outreg_line1' ctitle("Controls only") append
    
    reg   car4_250_100 ln_cvcount1 `rhsvars' if good==1, cluster(acq_gvkey)
    outreg2 using `outreg_file', `outreg_line1' ctitle("Current year only") append
    
    xtreg car4_250_100 ln_total_count_1yr `rhsvars' if good==1, fe i(acq_gvkey) vce(cluster acq_gvkey)
    outreg2 using `outreg_file', `outreg_line1' ctitle("Fixed Effects - Current year only") append

    Also, per Statalist protocol, I will mention that outreg2 is community-contributed (SSC).

    Comment


    • #3
      Hi, David!

      Thank you for the response. I found a way to use the append-part in the end of each regression, thank you!

      I did it like this:



      treg ln_ret100 MAIV1 avgEPU if new_Date<= 17136, fe robust

      estimates store pre_crisis

      outreg2 using tabell, excel

      xtreg ln_ret100 MAIV1 if new_Date<= 17136, fe robust

      estimates store pre_crisis1

      outreg2 using tabell, append excel

      xtreg ln_ret100 avgEPU if new_Date<= 17136, fe robust

      estimates store pre_crisis2

      outreg2 using tabell, append excel
      etc...

      Comment

      Working...
      X