Announcement

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

  • Adjusting values above 99.5th percentile

    I am working with American Community Service (ACS) data for 2016. My variable of interest in annual income (incwage) which is top coded at 99.5th percentile. Following the literature, I am looking to adjust top-coded annual income to 1.5 times of the top code. I am using the following code but it is not working.

    Code:
    generate topwage = 0
    summarize incwage [weight = perwt], detail
    local top = r(p99.5)
    replace topwage = 1 if incwage >= `top'
    
    generate income = 1.5 * incwage if towage == 1
    I believe the code local top = r(p99.5) does not work as when I replace p99.5 with p99 it works.

  • #2
    Code:
    r(p99.5)
    Is not a valid returned value from -summarize- nor is it legal syntax to use periods in Stata for names. You can see all that is returned after -summarize- by typing -return list- or reading the documentation for a particular command.

    You can get different percentiles from -help pctile-. For example

    Code:
    _pctile incwage, p(99.5)
    return list
    which will return results into -r(r1)-.

    Comment


    • #3
      Try:
      Code:
      centile incwage, centile(99.5)
      local top = r(c_1)
      That will make the code "work."

      However, I think the logic is wrong. If I understand what you have, the data you are working with already has censored the income variable at the value that is the 99.5th percentile in the Census Bureau's original data. The 99.5th percentile in your data set will be a different number. In fact, if I am understanding correctly, the value you want to find is not the 99.5th percentile of your data set but the maximum value in your data set. So I think you really want:
      Code:
      summarize incwage, meanonly
      local top = r(max)
      Also, the variable topwage is unnecessary, regardless of how you identify the observations that need to be recoded. You can just do whichever of the above is correct and then follow it by
      Code:
      generate income = 1.5 * incwage if incwage >= `top'
      Added: Crossed with #2

      Comment

      Working...
      X