Announcement

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

  • bysort: codebook

    I would like to quickly know the key stats (mean, quartiles) of a variable (age) across certain other variable (group).

    Naturally, my thought went to doing something like
    Code:
    bysort grp: codebook age
    Unfortunately, "codebook may not be combined with by".

    Any suggestions / workarounds to achieve the same result?

    I suppose I could do something like
    Code:
    codebook age if grp == 1
    etc i.e. a command for each group, but that's not very elegant, and if there are a lot of groups, then a bit unweildy.
    Thank you for your help!

    Stata SE/17.0, Windows 10 Enterprise

  • #2
    Code:
    help tabstat

    Comment


    • #3
      Code:
      help tabstat

      Comment


      • #4
        Thank you! Somehow it never occurred to me that tabstat does anything beyond means.
        Thank you for your help!

        Stata SE/17.0, Windows 10 Enterprise

        Comment


        • #5
          Code:
          bysort grp: tabstat age, stat(count mean min max p25 median p75)
          worked great for me.

          Follow up question:
          There are some categorical variables, for which I'd like to do the same, i.e. see the distribution across categories for different grp's. How could I achieve that? I understand that tabstat works for numerical variables only.

          UPDATE: That's a stupid question. That's what tab is for.
          Last edited by Pratap Pundir; 10 May 2022, 09:23.
          Thank you for your help!

          Stata SE/17.0, Windows 10 Enterprise

          Comment

          Working...
          X