Statalist The Stata Listserver


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

Re: st: state the same for multiple observations?


From   Scott Cunningham <[email protected]>
To   [email protected]
Subject   Re: st: state the same for multiple observations?
Date   Tue, 14 Nov 2006 09:50:03 -0500

us_id state
1 CA
1 CA
2 VA
3 PA
3 TX

I need to know if when a us_id has multiple observations is the state the same for each observation in that us_id. If the state is different for a given us_id I need to be able to easily identify those cases.

bysort us_id:  count if _n>1

That will let you determine first whether there exist multiples.

bysort us_id:  list if _n>1

That should let you list them.
*
*   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