Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: RE: creating deciles by location by year

From   Maria Yanotti <>
To   "" <>
Subject   st: RE: creating deciles by location by year
Date   Wed, 15 Aug 2012 02:10:26 +0000

Hi Alex,

maybe look into bysort

Maria Belen Yanotti
School of Economics and Finance
Room A262
Ph: 63243659

From: [] on behalf of Alexey Lyubimov []
Sent: Wednesday, 15 August 2012 11:28 AM
Subject: st: creating deciles by location by year

I am using Stata 11, I have a panel data set that has multiple years, locations, and companies.  I am trying to create deciles by year by location.
I use the following code to calculate deciles by year, but how can I add one more level and calculate by year by location?

gen size_decile = .
levelsof year, local(tempyear)
foreach i in `tempyear' {
xtile decile_temp=size if year==`i', nq(10)
replace size_decile = decile_temp if missing(size_decile)
drop decile_temp

Alex Lyubimov
Instructor/Ph.D. Candidate
Dixon School of Accounting
University of Central Florida

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index