Announcement

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

  • Displaying number of observations per t-test using esttab

    Dear Stata users,

    I am conducting t-tests on several variables in my sample. Due to missing values, the number of observations per test differs. Is there any way via the esttab command to display, for each test, either (A) the number of of observations by group directly under the mean (the red part in my picture below) or (B) total observations in a separate column (the blue part in my picture)? Either way would be great.

    Thanks for you help.

    My code is as follows:


    Code:
    global balance_desc firm_age  exporter size_num Retail Manuf Services foreign_perc
    
    recode treatment (1=0) (0=1)
    
    eststo balance: estpost ttest $balance_desc , by(treatment)
    
    esttab balance using "$path\temp\balance_FO_control.csv", plain cells("mu_1(label(Treated Firms $<$ 15 km) fmt(2)) mu_2(label(Control (Future SEZ))) b(label(Treatment-Control) star pvalue(p))" ". . p(label(p-value) par)")  replace label star(* 0.10 ** 0.05 *** 0.01)  title(Balance of Observables)




    Click image for larger version

Name:	stata.JPG
Views:	1
Size:	57.2 KB
ID:	1584792

  • #2
    You can use the
    e(count) option for the blue N (row). I was looking to have column N. Yet to find a solution.
    Code:
       
     esttab balance using "$path\temp\balance_FO_control.csv", /// plain cells("mu_1(label(Treated Firms $<$ 15 km) fmt(2)) /// mu_2(label(Control (Future SEZ))) b(label(Treatment-Control) star pvalue(p))" ". . p(label(p-value) par) count(fmt(0))") ///  replace label star(* 0.10 ** 0.05 *** 0.01)  title(Balance of Observables)

    Comment

    Working...
    X