 |
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: egen nth highest or lowest value
The code for, say, the lowest 5th value of variable x could be
sort x
gen tempvar = x in 5
egen newvar = mean(tempvar)
The code for the highest 5th value is
gsort - x
gen tempvar = x in 5
egen newvar = mean(tempvar)
Hope this helps,
Tamas
On 13/04/11, Caterina.ASTARITA@ec.europa.eu wrote:
> Dear Statalisters,
>
> is that possible to generate a new variable containing the nth lowest or nth highest value of another variable?
>
> Thanks
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
>
>
--
Tamas Bartus, PhD
Associate Professor, Deputy Director
Institute of Sociology and Social Policy
Corvinus University, Budapest
1093 Budapest, Közraktár utca 4-6.
Room 424.
Phone: +36-1-482-7301
Fax: +36-1-482-7348
Homepage: http://web.uni-corvinus.hu/bartus
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/