Statalist The Stata Listserver


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

st: RE: Re: state the same for multiple observations?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: state the same for multiple observations?
Date   Thu, 16 Nov 2006 11:37:44 -0000

Note also that this solution is written up at greater 
length in 

How do I list observations in a group that differ on a variable? 
http://www.stata.com/support/faqs/data/diff.html

i.e. this question is an FAQ. 

Nick 
[email protected] 

Michael Blasnik
 
> ...This should flag all observations within a us_id if there 
> is more than 
> one state listed for that us_id:
> 
> bysort us_id (state): gen byte diffstate=state[1]!=state[_N]

Marilyn Ibarra

> > Anyone have an idea of how I can do the following:
> >
> > The data looks something like this:
> >
> > 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.

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