Announcement

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

  • Esttab export, append multiple panels .rtf

    I am trying to append two panels into a single table using esttab with the append option.

    However, the output below does not look ideal and still a lot like two separate tables.
    1. The title is above the dependent variables
    2. The dependent variables are listed twice
    3. The table notes are twice
    4. There is in general too much space between the two panels.
    Click image for larger version

Name:	table.PNG
Views:	1
Size:	10.3 KB
ID:	1758110



    Do you know how to fix this and really get one table with two panels?


    Minimum working example

    Code:
    sysuse auto.dta, replace
    
    // regressions
    reg price mpg, robust
    estimates store ols1
    estadd local X "No", replace
    
    reg price mpg rep78 headroom trunk, robust
    estimates store ols2
    estadd local X "Yes", replace
    
    ivreg2 price (mpg=weight), robust
    estimates store iv1
    estadd local X "No", replace
    
    ivreg2 price (mpg=weight) rep78 headroom trunk, robust first
    estimates store iv2
    estadd scalar kpF = e(rkf)
    estadd local X "Yes", replace
    
    
    // Export top panel
    esttab ols1 ols2 using "table1.rtf", replace ///
        b(%8.3f) se(%8.3f) label keep(mpg) ///
        title("Panel A: OLS") star(* 0.10 ** 0.05 *** 0.01) ///
        stats(N X, labels("N" "Controls"))
        
    // Export bottom panel
    esttab iv1 iv2 using "table1.rtf", replace ///
        b(%8.3f) se(%8.3f) label keep(mpg) ///
        title("Panel B: IV") star(* 0.10 ** 0.05 *** 0.01) ///
        stats(kpF N X, labels("F-Stat" "N" "Controls"))    append

  • #2
    estout is from SSC, as you are asked to explain in FAQ Advice #12.

    1. The title is above the dependent variables
    This is a statement and doesn't specify what you want. Where else would the title be? The rest can be addressed using standard options.

    Code:
    sysuse auto.dta, replace
    
    // regressions
    reg price mpg, robust
    estimates store ols1
    estadd local X "No", replace
    
    reg price mpg rep78 headroom trunk, robust
    estimates store ols2
    estadd local X "Yes", replace
    
    ivreg2 price (mpg=weight), robust
    estimates store iv1
    estadd local X "No", replace
    
    ivreg2 price (mpg=weight) rep78 headroom trunk, robust first
    estimates store iv2
    estadd scalar kpF = e(rkf)
    estadd local X "Yes", replace
    
    
    // Export top panel
    esttab ols1 ols2 using "table1.rtf", replace ///
        b(%8.3f) se(%8.3f) label keep(mpg) ///
        title("Panel A: OLS") star(* 0.10 ** 0.05 *** 0.01) ///
        stats(N X, labels("N" "Controls")) nonotes
        
    // Export bottom panel
    esttab iv1 iv2 using "table1.rtf", replace ///
        b(%8.3f) se(%8.3f) label keep(mpg) ///
        title("Panel B: IV") star(* 0.10 ** 0.05 *** 0.01) ///
        stats(kpF N X, labels("F-Stat" "N" "Controls")) nonumbers nomtitles    append
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	21.4 KB
ID:	1758128

    Last edited by Andrew Musau; 08 Jul 2024, 09:02.

    Comment


    • #3
      deleted the answer, since it was cross-posted with #2, which solves it nicely.

      I will only add that if you want to do even more tweaking than esttab's own options allow, remember that you can also use the options for estout (esttab is a wrapper for estout). Furthermore, you can see the estout command that is executed internally by esttab by passing the noisily option to it. You can then tweak that command and use it instead of esttab itself.
      Last edited by Hemanshu Kumar; 08 Jul 2024, 09:20.

      Comment


      • #4
        That helps a lot, thanks!

        Re 1.: I wanted to have the "Panel A: OLS" above the Mileage and below Price. Is that possible? Maybe I should separate it to first have the top panel and then append the two main parts?

        Comment

        Working...
        X