Announcement

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

  • Summary statistics with weighted varibles

    Dear all, I would like to generate a variable reflecting the median of another variable - applying a weight (aweight).
    Therefore, -egen- does not work; is there any other solution to this? I am sorry for this very basic question. Any hints are very appreciated. Kind regards, Louisa

  • #2
    If you just want a variable containing the median value of another variable (and therefore a constant), use summarize with the option detail to get the 50th percentile and use that value to create your new variable:


    Code:
    sum var [aweight=WEIGHTVAR] , detail
    gen var_median = r(p50)
    tab var_median
    Last edited by Carole J. Wilson; 30 Mar 2016, 07:54.
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      FAQ: http://www.stata.com/support/faqs/da...ry-statistics/

      Comment


      • #4
        Dear Carole, dear Nick, thank you very much, this is highly appreciated. Kind regards, Louisa

        Comment

        Working...
        X