Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | George Murray <george.murray16@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Working with row percentiles and row averages |
Date | Tue, 9 Jul 2013 23:15:20 +1000 |
abcde 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). I would like to find, for each date, the average return of the stocks whose return is below that of the 10th percentile. That is, for the 10% of stocks with the lowest returns, I want to compute their average, for each date. I am aware that a command such as -egen p10 = rowpctile(r1-r1000), p(10)- generates a variable which computes the return of the 10th percentile at each date, but I don’t know how to go from here to find the average return below the 10th percentile, for each date. Any ideas for commands would be very highly appreciated. This is the first time I have had to work ‘by rows’, and am very stuck with this. Thank you. * * 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/