Announcement

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

  • How to use append in esttab

    Hi everyone I am using the following dataset and creating 2 tables
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(S1C_age S1C_married) byte S1C_educ float S1C_dep_ratio byte(S5_ben_training S6A_hh_mem_grp S6B_mem_wua)
    46 1  3         1 0 0 .
    37 1  3         1 1 0 .
    30 1  4         2 0 0 .
    46 1  3        .6 0 0 .
    55 1  3         1 1 0 .
    60 1  3  .3333333 0 0 .
    31 1  3  .5714286 1 0 .
    35 1  1 1.3333334 0 0 .
    51 1  3        .5 0 0 .
    38 1  3  .5714286 1 0 .
    59 0  4        .6 0 0 .
    45 1  3       .75 0 0 .
    29 1  2       2.5 0 0 .
    66 1  3      1.25 0 0 .
    24 1  3  .8333333 0 0 .
    50 1  3        .6 0 0 .
    29 1  3       1.5 0 0 .
    50 1  3 .44444445 0 0 .
    25 1  3         1 0 0 .
    54 0  3  .7272727 0 0 .
    59 1  3        .5 1 0 .
    65 0 10      .625 0 0 .
    56 1  3       .25 1 0 .
    36 1  4         1 0 0 .
    64 1  3  .3333333 0 1 .
    59 1  3         1 0 1 .
    64 1  3      .875 0 0 .
    64 0  3  .8888889 0 0 .
    33 1  3 1.3333334 1 0 .
    54 1  3  .7142857 0 0 .
    76 1  3         0 0 0 .
    44 1  3  .6666667 1 0 .
    27 0  3 .16666667 0 0 .
    26 1  3        .8 0 0 .
    46 1  2        .2 0 0 .
    48 1  3         1 0 0 .
    50 1  3         1 0 0 .
    63 0  3       .25 0 0 .
    52 0  3         1 0 0 .
    35 0  3  .4285714 0 0 .
    31 0  1        .6 0 0 .
    42 1  3       2.5 0 0 .
    43 1  3         1 0 0 .
    51 0  3 1.5714285 0 0 .
    47 1  3       1.2 0 0 .
    35 1  3       1.2 0 0 .
    50 0  3         1 0 0 .
    41 1  3      1.25 0 0 .
    37 1  3 1.0555556 0 0 .
    37 1  3  .6666667 0 0 .
    33 1  2       1.2 0 0 .
    35 1  3         2 0 0 .
    49 1  3         0 0 0 .
    54 1  3         0 1 0 .
    39 1  3  .6666667 0 0 .
    34 1  3         4 0 0 .
    26 1  3       1.2 0 0 .
    57 1  4 1.8333334 0 0 .
    31 1  3       1.2 0 0 .
    48 1  3         1 1 0 .
    41 1  3         2 0 0 .
    67 1  3         1 0 0 .
    55 1  7  .2857143 0 0 .
    33 1  3         2 0 0 .
    45 1  3 .44444445 0 0 .
    31 1  3  .6666667 0 0 .
    62 1  3      1.25 0 0 .
    56 0  5  .8333333 1 0 .
    22 1  6  .3333333 0 0 0
    50 1  3         0 0 0 .
    23 1  3        .4 0 0 .
    50 1  3        .4 0 0 .
    47 1  3       1.5 0 0 .
    67 1  2         1 0 0 .
    41 1  3       1.5 0 0 .
    37 1  3       .75 1 0 .
    61 1  4         1 0 0 .
    25 1  3       1.5 0 0 .
    32 0  2 1.3636364 0 0 .
    53 0  3  .8571429 0 0 .
    63 0  1       .75 0 0 .
    28 1  3         1 1 0 .
    38 1  3         1 0 0 .
    36 1  4         1 0 0 .
    26 1  4        .5 0 0 .
    26 1  2         1 0 0 .
    40 1  4 1.6666666 0 0 .
    44 1  3       .25 0 0 .
    39 1  4        .5 0 0 .
    48 1  3        .4 0 1 0
    42 1  3        .4 0 0 .
    56 1  3        .6 0 0 .
    54 1  3  .3333333 0 0 .
    45 1  3        .4 0 0 .
    41 1  3  .6666667 0 0 .
    55 1  4        .5 0 0 .
    50 1  3        .7 0 0 .
    57 0  3       .75 0 0 .
    33 1  3         2 0 0 .
    25 1  3        .5 0 0 .
    end
    first table i am using this code
    Code:
    global varlist S1C_age S1C_married S1C_educ S1C_dep_ratio S5_ben_training S6A_hh_mem_grp S6B_mem_wua
    
    estpost su $varlist
        est store summary_1    
    estpost su $varlist if S8_migrant ==1
        est store summary_2S1C_age S1C_married S1C_educ S1C_dep_ratio S5_ben_training S6A_hh_mem_grp S6B_mem_wua
    estpost su $varlist if S8_migrant ==0
        est store summary_3    
    
    esttab summary_* using "hh_sum.tex", replace tex ///
    cells("count(fmt(a2)) mean(fmt(a2)) sd(fmt(a2))") label mtitle("Overall" "Migrant Household" "Non-migrant Household") nonumber
    Second table is the difference in these variables

    Code:
    global varlist S1C_age S1C_married S1C_educ S1C_dep_ratio S5_ben_training S6A_hh_mem_grp S6B_mem_wua    
    estpost ttest $varlist, by (S8_migrant)
        esttab, wide nonumber mtitle("diff.")
        est store summary_1        
    esttab summary_* using "test.tex", replace tex ///
    cells("diff(fmt(a2))") label mtitle("Difference") nonumber
    I want to combine such that these two tables are one and only the difference result from the ttest is shown. right now i am not sure what i am doing incorrectly as the ttest only shows the number of observations. Thank you for your help in advance.

  • #2
    i just wanted to update

    I was using the wrong code for the ttest so the correct one is as below

    Code:
    global varlist S1C_age S1C_married S1C_educ S1C_dep_ratio S5_ben_training S6A_hh_mem_grp S6B_mem_wua    
    estpost ttest $varlist, by (S8_migrant)
        esttab, wide nonumber mtitle("diff.")
        est store summary_1        
    esttab summary_1 using "test.tex", replace tex ///
        eqlabels (`e(labels)') varwidth(20)
    I still dont know how to combine the tables if its different code when we combine horizontal way and vertical way? Or should we combine the table in latex? I also also wondering if anyone know why sometimes the decimal points are rounded and sometimes they are not.

    Thank you.

    Comment

    Working...
    X