Grouped income data in Stata or SAS I have an income distribution dataset which I am attempting to manipulate in Stata (or SAS).
I need to come up with a table listing the number of households earning between one income level and another. The income levels are regularly spaced, say at $10,000 intervals for example.
In other words, for $i=30,000$, I want to know the number of households $H_i$ receiving between 20,000 and 30,000.  And I want to know this for each i, at 10,000 dollar intervals, from 10,000 up to oh let's say 280,000.
$H_i=\int_{i-10000}^{i}f(x)\: dx$
$(0 < i\leq280000)$
(Where f(x) is the underlying density function representing households plotted along the y-axis, and x is income level, plotted along the x-axis. The distribution will have the skewed (lognormal-like) shape typical of income distributions.)
Does anyone know the Stata (or SAS) command that would give me this info? In Stata I can get the income at each percentile of the population using the "centile" command, but this doesn't quite give me what I want.
Thanks
 A: In Stata, assuming each case is a household,
gen i = autocode(x, 28, 0, 280000)
tab i

If cases represent multiple households, use weights with the tab command.
The help for autocode can be found under functions|programming functions.
A: 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

A: In SAS something like this could work:
data new;
 set old;
 inccat = floor(income/10000);
run;

proc freq data = new;
 table inccat;
run;

