[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Duha Tore Altindag" <daltin2@tigers.lsu.edu> |

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

Subject |
st: RE: Dividing Panel data into quartiles |

Date |
Thu, 16 Apr 2009 12:13:27 -0500 |

Although very amateurish, I think the following will work: sort firm year forval x=25(25) 75 { by year: egen p`x'=pctile(liquidity),p(`x') } forval x=25(25)75 { gen q`x'=0 replace q`x'=1 if liquidity>p`x' } egen quartile=rowtotal(q25-q75) replace quartile=quartile+1 -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of JIBONAYAN RAYCHAUDHURI Sent: Thursday, April 16, 2009 10:18 AM To: statalist@hsphsun2.harvard.edu Subject: st: Dividing Panel data into quartiles Hi, Statalistusers, I have a panel data set, with data on a number of firms over a number of years. Each observation is for a particular firm and year, and has various data for that observation. The firms are classified by a two digit industrial classification scheme called NIC2. I would like to divide my data into 4 quartiles or 5 quintiles, on the basis of one of my variables, liquidity. So I would like to create a variable, call it quartile, that has the value 1 if that observation for the firm is in the top quartile of liquidity for that year for that industry, has the value 2 if that observation is in the second quartile of liquidity for that year and industry, etc. (a firm might have different values of "quartile" in different years, depending on which quartile of liquidity it fits into in a particular year. The quartiles will probably contain somewhat different firms in each year.) The complication is that I want the firms divided into quartiles for each year and also each industry. I think the command xtile would probably work here to divide firms into quartiles, but I am not sure as to how the code would have to work to get all firms in a year sorted by industry and then divide them into quartiles, although it seems like it should be simple. Thanks in advance for any help! Jibonayan * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Dividing Panel data into quartiles***From:*JIBONAYAN RAYCHAUDHURI <jibonayanrc@yahoo.com>

- Prev by Date:
**st: AW: Dividing Panel data into quartiles** - Next by Date:
**st: Stata equivalent to st_matrixcolstripe?** - Previous by thread:
**st: AW: Dividing Panel data into quartiles** - Next by thread:
**Re: AW: st: AW: beta coefficients for interaction terms** - Index(es):

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