[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: xtile from the start of a period |

Date |
Tue, 26 Feb 2008 00:15:02 -0000 |

I don't know what a decile rank here is for certain. I guess it resembles a percentile rank as documented at How can I calculate percentile ranks? http://www.stata.com/support/faqs/stat/pcrank.html Also for filling in you might look at How can I replace missing values with previous or following nonmissing values or within sequences? http://www.stata.com/support/faqs/data/missing.html although what I am going to suggest is a standard application of -by:-. In your case, your structure is something like compid BY month BY market_value and so you can rank values in month 120, which is your first month, given your example and assuming use of the Stata date system. egen rank = rank(market_value) if month == 120 Ranks can be compared with the total number of companies using egen N = total(1) if month == 120 & rank < . although there are many other ways to get that number. Then your decile rank is perhaps something like gen decilerank = ceil(10 * rank / N) Those variables are defined for (at most) month 120. So you need to spread them to other values. bysort compid (month) : replace decilerank = decilerank[1] Nick n.j.cox@durham.ac.uk John Hund A simple question whose answer I can't find in the very interesting xtile by groups discussion. In this case I have data (market values) on companies (compid) monthly. Ideally I would like to generate a variable containing the decile rank of the company based on their market value at the beginning of a period (i.e. their decile in January 1970) and have that variable contain the decile rank for all monthly observations of the compid for a particular time window (i.e. 1970-1975). That is, there would be a variable that contains the decile rank from Jan70 for all monthly observations of a compid for the next 5 years. I suspect that my question is less about xtile and more about filling in, since it is easy to get the decile rank for the first month...I just can't "fill" it in for the next (in this case) 59 observations of each company. * * 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/

**Follow-Ups**:**st: Marginal effects of log-linear sample selection models***From:*Shehzad Ali <sia500@york.ac.uk>

**References**:**st: apostrophes, quotation marks, left or right quotes?***From:*Dirk Enzmann <dirk.enzmann@uni-hamburg.de>

**st: RE: apostrophes, quotation marks, left or right quotes?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: xtile from the start of a period***From:*John Hund <jhund@tulane.edu>

- Prev by Date:
**Re: st: Poisson model with interaction term** - Next by Date:
**st: Marginal effects of log-linear sample selection models** - Previous by thread:
**st: xtile from the start of a period** - Next by thread:
**st: Marginal effects of log-linear sample selection models** - Index(es):

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