Announcement

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

  • Tabulate summary statistics

    Hi everyone,

    I'm struggling to create a summary statistics table. I just cannot get the layout correctly.
    What I want is to get a single variable to be summarized under certain conditions:
    I want to get the mean, median, sd, min and max values for that variable, first for the overall sample and then across agegroups and gender conditional on marital status.

    I have tried estpost and outreg2 but failed with both.

    This is what I tried with estpost:

    Code:
    estpost sum probors1, d
    
    forvalues agegroup =1(1)5  {
        bysort married: eststo: estpost sum probors1 if `agegroup', d
    }
    bysort married: eststo: estpost sum probors1 if female==1, d
    bysort married: eststo: estpost sum probors1 if female==0, d

    And with outreg2 something like
    Code:
    bysort married: outreg2 using 23.xls, replace sum(detail) keep(probors1) eqkeep(mean p50 sd min max)
    But then I do not get the ,cross option working.

    The table should look something like:
    Code:
                    married                 not married
                    mean median sd min max    mean median sd min max
    overall
    agegroup
        1
        2
        3
    gender
        0
        1
    Many thanks for your time and help!

  • #2
    Welcome to the Stata Forum / Statalist.

    Thank you for having posted the commands under code delimiters, as recommended in the FAQ.

    I wonder whether the command - tabstat - woudn't do the trick for you, without the use of a loop.
    Best regards,

    Marcos

    Comment


    • #3
      Thank you Marcos for your reply.

      My biggest problem is not that I cannot obtain the right results, it's rather that I am not able to put those in a well-formated table.

      If I run the following
      Code:
      by agegroup female, sort : tabstat probors1, statistics( mean median sd min max ) by(married)
      I obtain all the results I need, but I want to learn the commands of how to put them in a table, which layout resembles the one from my initial post.

      Thank you so much for your help.

      Best,
      Frank

      Comment

      Working...
      X