If you're interested in Maarten's direction, then check out this Tip:
SJ-5-2 gr0014 Stata tip 20: Generating histogram bin variables
D. A. Harrison
Q2/05 SJ 5(2):280--281
tip illustrating the use of twoway__histogram_gen for
creation of complex histograms and other graphs or tables
(also reprinted in "33 Stata Tips" from StataCorp).
Nick
[email protected]
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Maarten buis
Sent: 23 January 2008 19:33
To: [email protected]
Subject: Re: st: RE: Interval Tabbing?
--- Rachel asked:
> What I'm looking to do is put a histogram in table form:
--- Nick Cox answered:
> At worst, this is two (or three) steps,
>
> 1. create categories
>
> (2. label them nicely)
>
> 3. tabulate
>
> But it can be compressed to one step:
>
> . findit tabcond
>
> . ssc inst tabcond
I was working along Nick's first suggestion and taking Rachel's
question literally: making a table from a histogram. The program below
allows you to do that, the relevant options from -histogram can also be
fed into -histtab-. Installation of this program is discussed in:
http://www.stata.com/statalist/archive/2008-01/msg00511.html
Hope this helps,
Maarten
*------ begin histtab.ado ---------------
*! version 1.0.0 MLB 23Jan2008
program define histtab
version 8.2
syntax varname, *
tempvar h x x2
twoway__histogram_gen mpg, gen(`h' `x') `options'
qui gen byte `x2' = _n if `x' < .
label variable `x2' `"`: variable label `x''"'
local start = r(start)
local rstart : di %9.2g `start'
local bin = r(bin)
local width = r(width)
local end = `start' + `width'
local rend : di %-9.2g `end'
tempname lab
label define `lab' 1 "`rstart' - `rend'"
forvalues i = 2/`r(bin)' {
local start = `end'
local rstart : di %9.2g `start'
local end = `end' + `width'
local rend : di %-9.2g `end'
label define `lab' `i' "`rstart' - `rend'", add
}
label values `x2' `lab'
tabdisp `x2' if `x2' < ., cellvar(`h')
end
*-------------------- end histtab.ado ------------------------------
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/