Announcement

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

  • means from multiple observations of multiple variables

    Dear statalists,

    say I have a data structure like this (see in the comment below).

    How can I then get the mean of all prizes without having to take means of means?

    Thank you!
    Last edited by Felix Stips; 01 Oct 2019, 09:08.

  • #2
    prize 1 prize 2 prize 3
    3 4 5
    6 2 2

    Comment


    • #3
      Felix:
      Do you mean something along the following lines?
      Code:
      . stack prize_1 prize_2 prize_3 , into( prize_tot )
      Warning:  data in memory will be lost.
               Press any key to continue, Ctrl-Break to abort.
      
      . tabstat prize_tot, stat(count mean sd p50 min max)
      
          variable |         N      mean        sd       p50       min       max
      -------------+------------------------------------------------------------
         prize_tot |         6  3.666667  1.632993       3.5         2         6
      --------------------------------------------------------------------------
      
      .
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Yes, the stack does the trick, thank you. Wow, I didn't expect that a command would exist for this case.

        Comment


        • #5
          Felix:
          having a sort of mental dashboard that helps you to retrieve the Stata commands you need (even though you do not use them regularly) is really rewarding and pays back many times more the hours you devoted to study Stata and its several features.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Stata has some nice "cheat sheets" available with Stata commands. Look at
            https://www.stata.com/links/resource...g-stata/#cheat

            Comment

            Working...
            X