Announcement

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

  • Changing the Column Titles and adding notes using Outreg2

    I am trying to export a table of summary statistics using the following command:

    outreg2 using "results.doc", replace sum(log) keep(compost recycling inc popden hhsize) eqkeep(mean sd min max) title("Summary Statistics") ctitle(Mean, Standard Deviation, Minimum, Maximum)

    I would however like to change the four column titles to Mean, Standard Deviation, Minimum and Maximum, however this command only changes the first column.
    I would also like to add notes at the bottom of the table but do not know how to do this.

    Any help is greatly appreciated!

  • #2
    Dear Darcy, how about trying to use this command -asdoc-?
    I think it's more convenient compared with outreg2
    2B or not 2B, that's a question!

    Comment


    • #3
      Hi Darcy,

      So I thought that in outreg2 you had to add a new ctitle() for each new column. To add notes to the bottom, use addnote(). I always put the addnote() in the first time I invoke outreg2 in a set of regressions (I don't know what would happen if I put it in later lines--it may be possible, but I've never tried). (For those coming later, note that outreg2 is installed from SSC.)

      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
      * So I can just 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

      Comment


      • #4
        Liu, I will investigate asdoc.

        David, I can change the column title for normal regression, the problem here is I am creating a summary stat table so all four columns come at once, rather than adding one column title with each regression? The addnote worked a treat though thank you!

        Comment


        • #5
          Darcy Hill,

          I've never had much luck using outreg2 for descriptive statistics (even though I always use oureg2 for regression tables). I always use logout or mkcorr (both from SSC for those)

          Code:
          * This is the code that worked for me
          local rhsvars "acq_size acq_rd acq_q target_age target_public target_patents"
          local tab_table "C:\Data\Tables for R&R\Table 1 - Tabstat Table"
          logout, save(`tab_table') excel replace: tabstat `rhsvars' if good==1, stats(n mean median p25 p75 min max) col(stats)
          mkcorr  `rhsvars' if good==1, replace means log(`log_file') num cdec(3)  /* Creates txt file that can be imported in Excel */
          * "means" option means summ (so "n mean sd min max"); NUM option means "number the variables & put across the top"
          You might also try tabout (SSC install tabout). For examples of tabout tables visit the official on-line gallery and consult the User Guide (skip down to chapter 3). A similar Tabout user guide is available at ResearchGate (you may need to register to download it). But it has a number of really nice tables / crosstabs of survey data (& the Stata code to create them). Link

          Comment

          Working...
          X