Announcement

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

  • Inverse to _pctile ?

    For the purpose of creating a table, I want to include the percentile of a given value within the distribution of a variable. In other words, if I have a variable named dens I'd like to know what percentile corresponds to value 0.229. I do not need to create a new variable with this value, but only to get the number in memory.

    I've seen that
    _pctile does the opposite:

    _pctile dens, p(15)

    This will result in:

    . return list

    scalars:
    r(r1) = .0229039993137121


    Implying that the value 0.0229 corresponds to the 15th percentile in the distribution of dens.

    Yet, I'm looking for a command in which I can input the value 0.0229 and STATA will return the percentile 15, in this example.

    Thanks.
    Last edited by Dany Bahar; 25 Jul 2017, 14:31. Reason: percentile

  • #2
    Do you want something like

    Code:
    sysuse auto
    _pctile price , p(15)
    return list
    
    count if price < r(r1)
    display r(N)/c(N)
    Best
    Daniel
    Last edited by daniel klein; 25 Jul 2017, 14:58.

    Comment


    • #3
      Exactly right. Thank you very much!

      Comment

      Working...
      X