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

Re: A simpler count question Re: st: RE: Re: Counts of differentvalues in one variable by another variable


From   Edwin Leuven <e.leuven@uva.nl>
To   statalist@hsphsun2.harvard.edu
Subject   Re: A simpler count question Re: st: RE: Re: Counts of differentvalues in one variable by another variable
Date   Fri, 26 Mar 2004 16:24:47 +0100 (CET)

one way is

sort x
count if x!=x[_n-1]



On Fri, 26 Mar 2004, SamL wrote:

> I want to know how many values of variable X there are in my data.  I
> don't need to know the frequency distribution of X, I need to know how
> many values of X there are.  For example, if the true frequency
> distribution is:
> 
> Value    Frequency   Pct
> 1          8          8.0
> 2         20         20.0
> 3         30         30.0
> 4         20         20.0
> 7         12         12.0
> 15        10         10.0
> 
> then, I only want a count of the Value column (which is 6 in the case
> above).  My problem is that I -tab1- a variable but there are too many
> values for it to run the frequency distribution.  I could use by, but that
> could get very tedious with counting, and could be prone to error when I
> add up across the by variable.  I expect there to be something on the
> order of 3700 values, but I have to check to be sure.
> 
> My check of the manual and the stata web-site turned up nothing, but
> perhaps I do not know for what command or keyword I should search.
> 
> Ideas appreciated.
> 
> Thanks.
> Sam
> *
> *   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/
> 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index