Announcement

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

  • Table of summary statistics - Esstab for reporting count per category

    Hi all,

    I have created a table reporting the mean and SE across treatments for two variables.

    I would like to include the number of observations per treatment in the last row.

    I am aware of the obslast command for the esttab command, however, this does not seem to report per category?

    If anyone can pick up my error regarding this, I would greatly appreciate any hints.

    ------------------------------------------------------------------------
    Control Social Environmen~l Soc*Env
    ------------------------------------------------------------------------
    Stated WTP for OE 57.71 65.09 64.50 7.0.08
    (32.69) (38.11) (45.86) (38.29)

    Stated WTP for DC 11.29 12.63 12.17 22.55
    (29.13) (32.59) (29.21) (36.27)
    ------------------------------------------------------------------------
    Observations 362 (this is total) I need per category X X X
    ------------------------------------------------------------------------



    Here is my command

    Code:
     
     est clear estpost tabstat P_OE P_DC, by(Treatment_Group) /// c(stat) stat(mean sd count) nototal    ereturn list esttab, main(mean %8.2fc) aux(sd  %8.2fc) nostar nonumber unstack ///    nonote label ///    collabels(none) ///    eqlabels("Control" "Social" "Environmental" "Soc*Env") ///     nomtitles            esttab using "table1.tex", replace ///   main(mean %8.2fc) aux(sd %8.2fc) nostar nonumber unstack ///    compress nonote gap label booktabs   ///    collabels(none) ///    eqlabels("Control" "Social" "Environmental" "Soc*Env") ///      nomtitles
    an here is some sample data

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(P_OE P_DC) byte Treatment_Group
    10  0 1
    10  0 3
     2  0 2
    25  0 4
    11  0 1
    15  0 3
    15  0 2
    25  0 4
    15  0 1
    20  0 3
    15  0 2
    25  0 4
    20 49 1
    20  0 3
    20  0 2
    20  0 1
    30  0 4
    20  0 3
    20  0 2
    25  0 1
    20  0 3
    25  0 2
    30 59 4
    25  0 1
    20  0 3
    25  0 2
    30  0 4
    25  0 1
    22  0 3
    25  0 2
    25  0 1
    35  0 4
    22  0 3
    25  0 2
    30  0 1
    35  0 4
    24  0 3
    30  0 2
    30  0 1
    25  0 3
    30  0 2
    35  0 4
    30  0 1
    25  0 3
    30  0 2
    35  0 4
    30  0 1
    25  0 3
    30  0 2
    30  0 1
    35  0 4
    30  0 3
    35  0 2
    30  0 1
    40  0 4
    30  0 3
    35  0 2
    30  0 1
    30  0 3
    40  0 4
    35  0 2
    30  0 1
    30  0 3
    35  0 2
    32  0 1
    40  0 4
    30  0 3
    35  0 2
    35  0 1
    40  0 4
    30  0 3
    35  0 1
    35  0 2
    40 39 4
    32  0 3
    35  0 1
    35  0 2
    33  0 3
    40 59 4
    35  0 1
    40  0 2
    33 39 3
    35  0 1
    40  0 2
    40 89 4
    35  0 3
    35  0 1
    40  0 2
    40  0 4
    35  0 1
    35 69 3
    40  0 2
    45  0 4
    35  0 1
    35  0 3
    40  0 2
    35  0 1
    45 39 4
    35  0 3
    40  0 2
    end
    label values Treatment_Group Treatment_labels
    label def Treatment_labels 1 "1. Control", modify
    label def Treatment_labels 2 "2. SOC", modify
    label def Treatment_labels 3 "3. ENV", modify
    label def Treatment_labels 4 "4. SOC*ENV", modify

  • #2
    Duplicate post. If interested, see https://www.statalist.org/forums/for...=1677008003240

    Comment

    Working...
    X