Announcement

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

  • bivariate tabstat

    I often want a bivariate version of the tabstat command. Let me explain what I mean.

    The tabulate command can cross-tabulate two variables: for example "tab x y".
    The tabstat command can give the mean (or other statistic) of one variable for each value of another: for example "tabstat z, by(x)".

    What I'd like is a command that can do both of these things at once, giving the mean (or other statistic) of one variable for each combination of two others. If tabstat could do this, the syntax might be "tabstat z, by(x y)".

    Is there a command that can do what I'm suggesting?

  • #2
    depending on what statistics you want, either -tab- or -table- will do; see
    Code:
    help tabulate_summarize
    help table

    Comment


    • #3
      As Rich pointed out, try something like:

      Code:
      table catvar1 catvar2, c(mean contvar)
      Also:

      Code:
      tabulate catvar1 catvar2, summarize(contvar) means
      Best regards,

      Marcos

      Comment


      • #4
        Oh! I didn't know tabulate would do that. Can tabstat do anything that tabulate cannot?

        Comment


        • #5
          The best way to check it out is just typing - help tabstat - and - help tabulate - and verify the examples as well as the options.
          Best regards,

          Marcos

          Comment


          • #6
            tabstat can do many things that tabulate can't. So, sometimes you need a two-step:

            Code:
            egen both = group(x y), label 
            tabstat z. by(both)

            Comment

            Working...
            X