Announcement

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

  • Summary statistics for subpopulation compared to WHOLE population

    Dear Stata experts,

    I want to show some summary statistics for
    a) my whole sample and
    b) a subpopulation for which I have additional data

    How can I do this? When I create a dummy for whether I have additional data, I only compare the subpopulation with the rest.
    However, I'd like to have the statistics for the subpopulation and the whole population (including the subpopulation).

    Thank you very much for your help!
    Simon

  • #2
    Code:
    // WHOLE SAMPLE SUMMARY STATISTICS
    summ var1 var2 var3 /*etc.*/
    tab1 discrete1 discrete2 discrete3 /*etc.*/
    
    // SUBSAMPLE SUMMARY STATISTICS
    summ var1 var2 var3 /*etc.*/ if in_subsample == 1
    tab1 discrete1 discrete2 discrete3 /*etc.*/ if in_subsample == 1
    where in_subsample is an indicator variable taking on the value 1 in your subpopulation and 0 in all other observations.

    Comment


    • #3
      Thank you very much, Clyde!

      Is there an option to have both summary statistics in one table?

      E.g. with the by prefix similar to this example from the manual?
      With this option I've only been able to compare the subsample (in_subsample== 1) with the rest (in_subsample== 0) so far. But as I said, I want the whole sample and not the rest.

      Click image for larger version

Name:	using by option.png
Views:	1
Size:	58.0 KB
ID:	1460835



      Thanks in advance and best regards!
      Simon

      Comment


      • #4
        Simon:
        try:
        Code:
        tabstat price mpg rep78, by(foreign)
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks a lot, Carlo!
          Looks already pretty good, but my sample-descriptions are truncated, is there an option to show more characters or do I need to find a shorter description?

          Comment


          • #6
            Simon:
            I've never checked about widening the space for variable description in a given table.
            If feasible (and readable), I would recommend abbreviations and a legend at the foot of the table.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Ok. Grazie mille, Carlo!

              Comment

              Working...
              X