Hallo Erasmo,
You can try it by creating a local with all your years and then run the
xtile in combination with the if command. That's the way I did it:
------------
gen size_decile = .
levelsof yearvar, local(tempyear)
foreach i in `tempyear' {
xtile decile_temp=size1 if yearvar==`i', nq(10)
replace size_decile = decile_temp if missing(size_decile)
drop decile_temp
}
--------------
Regards,
Alex
.
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Erasmo Giambona
> Sent: Monday, July 16, 2007 4:25 PM
> To: statalist
> Subject: st: how can I create deciles by group?
>
> Dear Statalist,
>
> I need to create deciles for my dataset by year. I understand STATA
> allows one to get deciles for the full data set (in my case I used:
> xtile size_decile=size1, nq(10)), but I really need to get my deciles
> by year. I realize that the "by" group does not work with "xtile". Is
> there any way to get the size deciles by year?
>
> I would appreciate any suggestions.
>
> Regards,
> Erasmo
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/