# STATA - Splitting panel data into quartiles

#### ryaaaaan2007

##### New Member
I am new to this stuff so please excuse me if an answer already exists but I certainly can't find it.

I have a large panel dataset in STATA and want to know how I can split the data into quantiles (deciles preferably) of a certain variable, but by year.

To be more specific, I have data on firms' excess equity returns (which will form the dependent variable of my regression) from 1971-2011 and a large number of explanatory variables. I want to run regressions but only for firms in the bottom 3 deciles of Firm Size (one of my explanatory variables). Critically, it must be the bottom 3 deciles of for year. So the bottom 3 deciles of Firm Size for 1971, then the bottom 3 deciles for 1972 etc. etc.
Then the observations I am left with will form that particular regression.

Many thanks for help,

Ryan

#### bukharin

##### RoboStataRaptor
Use the third-party program -xtile2-:
Code:
ssc install xtile2