Hi guys,
I'm trying to collapse a large dataset by year, gender, and economic sector but instead of the usual percentile groups I'm trying to use quintiles, or deciles.
I know that xtile is a popular command but it doesn't work with by or with bysort , and I'm splitting things by three dimensions. I outline an example using the unions dataset below.
I know how to make this work for a given percentile, so for the tenth percentile I could write this
The only problem is I want to scale up from percentiles to deciles or quintiles. Something which would look kind of like this.
Does anyone have any ideas? Any help would be appreciated.
I'm trying to collapse a large dataset by year, gender, and economic sector but instead of the usual percentile groups I'm trying to use quintiles, or deciles.
I know that xtile is a popular command but it doesn't work with by or with bysort , and I'm splitting things by three dimensions. I outline an example using the unions dataset below.
Code:
webuse union , clear tab1 year union black age
I know how to make this work for a given percentile, so for the tenth percentile I could write this
Code:
collapse /// (p10) age (count) N=age, /// by(year union black)
Code:
collapse /// (p1-p10) age (count) N=age, /// by(year union black)
Comment