To finish: an observation is going to lie beneath, above or on a given
percentile for it's group, so there's a smarter (more efficient) algorithm,
but a brute-force approach is shown below.
Joseph Coveney
clear *
set more off
set seed `=date("2007-09-29", "YMD")'
set obs 100
generate byte pid = _n
generate byte group = mod(_n, 10)
generate double response = uniform()
*
* Begin here
*
tempvar tmpvar0 tmpvar1
sort group
generate double p75 = .
generate double `tmpvar0' = .
quietly forvalues i = 1/`=_N' {
replace `tmpvar0' = response if _n != `i'
by group: egen double `tmpvar1' = pctile(`tmpvar0'), p(75)
replace p75 = `tmpvar1' in `i'
drop `tmpvar1'
replace `tmpvar0' = .
}
drop `tmpvar0'
list in 1/20, noobs sepby(group)
exit
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/