Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: percentiles and locating a scalar in there.


From   "Jann Ben" <[email protected]>
To   <[email protected]>
Subject   st: RE: percentiles and locating a scalar in there.
Date   Wed, 27 Jul 2005 12:00:27 +0200

Have you seen -relrank- from SSC (type -ssc install relrank-)?
I think it does what you want. Example:  

 . clear
 . set obs 1000
 . gen x=_n
 . gen s=20 in 1
 . relrank s, ref(x) g(p)
 . di p[1]
 .02

I also have a Mata version of the -relrank- program, if you are 
interested. 
ben

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> NEYMOTIN, FLORENCE
> Sent: Tuesday, July 26, 2005 12:46 AM
> To: [email protected]
> Subject: st: percentiles and locating a scalar in there.
> 
> 
> Hi, I have a question regarding percentiles that I've been 
> having some trouble with...suppose that 
> you have a variable x, and you have a scalar s, and you'd 
> like to know at about what percentile of 
> the x variable the s scalar falls.  For instance, suppose 
> x=1,2,3,...,1000.  Then if you have 
> s=20, it should be assigned the percentilie value of the 2nd 
> percentile.  Is there a way to do 
> this easily in stata? (I wanted to assign the scalar a n 
> approximate percentile EVEN IF IT'S NOT A 
> VALUE in the variable itself so it can't be located in there) 
>  Everything I could think of would 
> take quite a while.
> Thank you for your help,
> Florence
> *
> *   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/
> 

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index