Search code examples
statatrim

Trimming data in Stata


I have a data set and want to drop 1% of data at one end. For example, I have 3000 observations and I want to drop the 30 highest ones. Is there a command for this kind of trimming? Btw, I am new to Stata.


Solution

  • You can use _pctile in Stata for that.

    sysuse auto, clear
    _pctile weight, nq(100)
    return list  #this is optional 
    drop if weight>r(r99) #top 1 percent