Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: creating deciles by location by year


From   Alexey Lyubimov <alyubimov@bus.ucf.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: creating deciles by location by year
Date   Tue, 14 Aug 2012 21:28:25 -0400

Hi,
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
407-823-1477
alyubimov@bus.ucf.edu



*
*   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/


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