Collapsing variables

Hey there,

I am new to STATA and would like to solve the following problem:
Lets say that I have variable "consumption of cereals" and variable "net income". I would like to find out how much of cereals is consumed in average by the poorest 10% and the richest 10% of the population in my dataset. Any command which I could use? I will appreciate your suggestions. Thank you

Best regards,

You don't need to use the collapse command.

Just use syntax similar to the following with _pctile.

sysuse auto, clear
tab weight

_pctile weight, nq(100)
gen lowpct = weight <= r(r10)
tab weight if lowpct

_pctile weight, nq(100)
gen hipct = weight >= r(r90)
tab weight if hipct
If you don't understand what r(r10) and r(r90) are, see the following:

_pctile weight, nq(100)
return list
For more help on working with percentiles see,

help pctile
You could also get deciles using the following:

summarize weight, detail
return list
For help, see:

help summarize
Last edited: