Announcement

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

  • obtaining the corresponding average length of stay for gross bill that are in percentiles

    Hi, appreciate your help on this. I had obtained the summary statistic of gross_bill, with the percentiles (p1, p5, p10, p25, p50, p75, p90, p95, p99) result. What I would like is the corresponding average LOS (length of stay) for these percentiles. So, if row 1 to row 3 is in the 1st percentile, the average LOS would be (5+4+2)/3 = 3.6. How can I code this up?

    +------------------+
    gross_bill los
    -----------------
    1. 5906.141 5
    2. 6579.505 4
    3. 6732.888 2
    4. 7953.42 6
    5. 8166.664 6
    -----------------
    6. 8199.374 6
    7. 8284.317 6
    8. 8317.767 7
    9. 8342.141 5
    10. 8426.037 7
    +-----------------+


    many thanks!

  • #2
    You say that you have the percentiles, but they don't actually appear in the sample of data you show. So I'm going to start by assuming you have another variable you didn't show us, called gb_pctile that identifies each of these groups.
    Code:
    egen mean_los = mean(gross_bill), by(gb_pctile)

    Comment

    Working...
    X