Announcement

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

  • eststo estpost of categorical variables

    Hello everyone,
    I have been trying to generate a self-explanatory table with the mean and standard deviation of the demographic characteristics of my sample (age band, gender, education, marital status). Ideally, I would also like to get these stats for the five waves of my survey (as columns of the table).
    However, all the four variables are categorical. If I do something like: "eststo Table1: estpost summarize i.age i.gender i.education i.marital", I obtained that factor-variable and time-series operators are not allowed.
    How can I solve the issues?
    Thank you

  • #2
    estpost is part of estout from SSC, as you are asked to explain (FAQ Advice #12). Use the -xi- prefix.

    Code:
    sysuse auto, clear
    xi: estpost summarize i.rep78
    Res.:

    Code:
    . xi: estpost summarize i.rep78
    i.rep78           _Irep78_1-5         (naturally coded; _Irep78_1 omitted)
    
                 |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd)     e(min)     e(max)     e(sum) 
    -------------+----------------------------------------------------------------------------------------
       _Irep78_2 |        69         69    .115942   .1040068   .3225009          0          1          8 
       _Irep78_3 |        69         69   .4347826   .2493606   .4993602          0          1         30 
       _Irep78_4 |        69         69   .2608696   .1956522   .4423259          0          1         18 
       _Irep78_5 |        69         69   .1594203   .1359761   .3687494          0          1         11

    Comment


    • #3
      Thank you for answering Andrew Musau! I had already tried it but one category is omitted. I would like to have every single age bands with their corresponding labels....Do you maybe know another way to overcome the issue? Thanks again.

      Comment


      • #4

        I had already tried it but one category is omitted.
        From

        Code:
        help xi
        noomit prevents xi from omitting groups. This option provides a way to generate an indicator variable for every category having one or more variables, which is useful
        when combined with the noconstant option of an estimation command.
        So:

        Code:
        sysuse auto, clear
        xi, noomit: estpost summarize i.rep78 i.foreign
        Res.:

        Code:
        . xi, noomit: estpost summarize i.rep78 i.foreign
        
                     |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd)     e(min)     e(max)     e(sum) 
        -------------+----------------------------------------------------------------------------------------
           _Irep78_1 |        69         69   .0289855   .0285592   .1689948          0          1          2 
           _Irep78_2 |        69         69    .115942   .1040068   .3225009          0          1          8 
           _Irep78_3 |        69         69   .4347826   .2493606   .4993602          0          1         30 
           _Irep78_4 |        69         69   .2608696   .1956522   .4423259          0          1         18 
           _Irep78_5 |        69         69   .1594203   .1359761   .3687494          0          1         11 
         _Iforeign_0 |        74         74   .7027027   .2117734   .4601885          0          1         52 
         _Iforeign_1 |        74         74   .2972973   .2117734   .4601885          0          1         22
        I would like to have every single age bands with their corresponding labels....Do you maybe know another way to overcome the issue?
        You could write a program that loops through the value labels and assigns these as variable labels of the created indicators, but if you have Stata 17 or later, I would recommend that you take a look at the collect suite of commands.

        Code:
        help collect

        Comment

        Working...
        X