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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

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

Date |
Thu, 16 Apr 2009 18:09:19 +0200 |

<> You want to check carefully whether this does what you want. At the very least, it contains some useful techniques if you do decide to waste information... How low can liquidity go? I assumed 0... ************* clear* local obs 10000 set obs `obs' egen float firmid = seq(), from(1) to(`obs') block(10) egen float year = seq(), from(1) to(10) block(1) gen byte industry=irecode(runiform(),0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1) bys firmid: g liquidity =20000+rnormal()*10 if _n==1 bys firmid: replace liquidity=liquidity[_n-1]+rnormal()*10 if _n!=1 forv i=25(25)75{ bys year industry: egen pctile`i'= pctile(liquidity) , p(`i') } bys year industry: gen quartile=irecode(liqui, 0, pctile25,pctile50,pctile75) sort firmid industry year //l, noo sepby(firm indu) // if you want to get rid of pctile, comment out below // drop pctile?? ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von JIBONAYAN RAYCHAUDHURI Gesendet: Donnerstag, 16. April 2009 17:18 An: statalist@hsphsun2.harvard.edu Betreff: 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:
**RE: AW: st: AW: Quotes for scalar within local (was efficiently run three loops (or do without them))** - Next by Date:
**st: RE: Dividing Panel data into quartiles** - Previous by thread:
**st: RE: Dividing Panel data into quartiles** - Next by thread:
**st: RE: Dividing Panel data into quartiles** - Index(es):

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