In Stata, you can achieve this as follows:
clear
set seed 99
set obs 1000
gen inc = 10000 * exp(invnorm(uniform()))
gen lb = floor(inc/10000) * 10000
tabulate lb
This code creates left-bounded intervals, i.e. including the lower bound, but excluding the upper bound.
If you prefer the count
approach, you can use the following code:
forvalues n = 0(10000)280000 {
count if inrange(inc, `n', `n' + 10000)
}
Note that the inrange
function refers to left-bounded intervals too.
If you need a table to be inserted in a document, you can add the following lines:
collapse (count) N = inc, by(lb)
gen interval = "[" + string(lb) + ";" + string(lb + 10000) + ")"
list interval N, sep(0) noobs