Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Computing percentiles for each date
From
George Murray <[email protected]>
To
[email protected]
Subject
st: Computing percentiles for each date
Date
Mon, 8 Jul 2013 14:52:48 +1000
Dear Statalist,
I am working with time series data, and my variables consist of
monthly returns for 1000 stocks (so the variables are
date,r1,r2,r3,...,r1000). For each date, I would like to find the 90th
percentile-return. That is, the return of the stock with the 100th
highest return, at each date.
I have tried using -by date: egen p90 = pctile(r1-r1000)-, but Stata
interprets the 'r1-r1000' as the variable defined by r1 minus r1000,
rather than the 90th percentile of the returns at each date. This
approach works if I want to find the mean return at each date, using
-egen mean = rmean(r1-r1000)-, but I am not sure if there is an
equivalent code to find percentiles. Does anyone have any ideas on how
to do this?
Thanks in advance.
George.
*
* 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/