[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
SamL <saml@demog.berkeley.edu> |

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 08:50:54 -0800 (PST) |

Answers! Edwin Leuven's suggestion worked: sort x count if x!=x[_n-1] Thanks for all the help. Sam On Fri, 26 Mar 2004, Nick Winter wrote: > At 07:15 AM 3/26/2004 -0800, you wrote: > >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. > > One approach is to upgrade to Stata/SE, whose -tabulate- command can handle > up to 12,000 rows. So you could do > > . quietly tab x > > and then grab r(r) > > If the values are all integers, then the command -levels- (available from > SSC) might do the trick for you. > > Or, from first principles: > > . bysort x: gen count = (_n==1) > . replace count = sum(count) > . sum count > > and grab r(max) > > --Nick Winter > > --Nick Winter > > > -------------------------------------------------------- > Nicholas Winter 607.255.8819 t > Assistant Professor 607.255.4530 f > Department of Government nw53@cornell.edu e > 308 White Hall falcon.arts.cornell.edu/nw53 w > Cornell University > Ithaca, NY 14853-4601 > > * > * 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/

**References**:**st: RE: Re: Counts of different values in one variable by another variable***From:*"Donnell Butler" <djbutler@princeton.edu>

**Re: A simpler count question Re: st: RE: Re: Counts of different values in one variable by another variable***From:*Nick Winter <nw53@cornell.edu>

- Prev by Date:
**Re: A simpler count question Re: st: RE: Re: Counts of different values in one variable by another variable** - Next by Date:
**RE: A simpler count question Re: st: RE: Re: Counts of different values in one variable by another variable** - Previous by thread:
**Re: A simpler count question Re: st: RE: Re: Counts of different values in one variable by another variable** - Next by thread:
**st: Data manipulation** - Index(es):

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