Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: table with nested categories


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: table with nested categories
Date   Mon, 15 Sep 2003 10:56:01 +0100

Al Pasaoa asked 
 
>    I want to get a one-way table of statistics of a 
> variable X, where X is decomposed by nested inequalities, such as:
> 
> X>0
> X>5
> X>10
>  etc.
> 
> Is there a simple command/option for this in Stata?

Nada Wasi suggested 

> how about this?
> -construct the new variable,Y, to separate X into
> groups:
> gen Y = 1 if X>0
> replace Y = 2 if X>5
> replace Y = 3 if X>10
> :
> (you could label Y if you want).
> -then, use the command "table" 
> table Y, c(mean Y,...)

I think Nada misses a key point here, that the inequalities 
are to be nested, so the variables created would have 
to be different. 

Alternatively, -tabcount- from SSC will do this for you. 

. ssc inst tabcount 
. tabcount X, c(>0 >5 >10) 

Nick 
[email protected] 

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index