Hello
I've got a panel dataset that has firms observed in years 2005 - 2013. I would like to place firms into ten buckets based on their incomegrowth in 2009. And then table (or better - plot) mean incomegrowth of each bucket for 2006 - 2013. I've used the code below to create the buckets in 2009. But how do I assign the same bucket value for all other years of the same id?
gen growthcat2009 = .
_pctile incomegrowth_p if year==2009, p(10(10)90)
replace growthcat2009=10 if incomegrowth_p>r(r1) & year==2009
replace growthcat2009=20 if incomegrowth_p>r(r2) & year==2009
replace growthcat2009=30 if incomegrowth_p>r(r3) & year==2009
replace growthcat2009=40 if incomegrowth_p>r(r4) & year==2009
replace growthcat2009=50 if incomegrowth_p>r(r5) & year==2009
replace growthcat2009=60 if incomegrowth_p>r(r6) & year==2009
replace growthcat2009=70 if incomegrowth_p>r(r7) & year==2009
replace growthcat2009=80 if incomegrowth_p>r(r8) & year==2009
replace growthcat2009=90 if incomegrowth_p>r(r9) & year==2009
Thank you
Tamara
I've got a panel dataset that has firms observed in years 2005 - 2013. I would like to place firms into ten buckets based on their incomegrowth in 2009. And then table (or better - plot) mean incomegrowth of each bucket for 2006 - 2013. I've used the code below to create the buckets in 2009. But how do I assign the same bucket value for all other years of the same id?
gen growthcat2009 = .
_pctile incomegrowth_p if year==2009, p(10(10)90)
replace growthcat2009=10 if incomegrowth_p>r(r1) & year==2009
replace growthcat2009=20 if incomegrowth_p>r(r2) & year==2009
replace growthcat2009=30 if incomegrowth_p>r(r3) & year==2009
replace growthcat2009=40 if incomegrowth_p>r(r4) & year==2009
replace growthcat2009=50 if incomegrowth_p>r(r5) & year==2009
replace growthcat2009=60 if incomegrowth_p>r(r6) & year==2009
replace growthcat2009=70 if incomegrowth_p>r(r7) & year==2009
replace growthcat2009=80 if incomegrowth_p>r(r8) & year==2009
replace growthcat2009=90 if incomegrowth_p>r(r9) & year==2009
Thank you
Tamara
Comment