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   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: state the same for multiple observations?
Date   Tue, 14 Nov 2006 12:17:36 -0500

At 09:41 AM 11/14/2006, you wrote:
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.

Thanks in advance,
Marilyn.
Several solutions have already been given.

Another is -funcdep- in my -collapseunique- module in SSC.

funcdep state, basis(us_id) gen(diffstate)

Thus, Marylin's question is whether state is functionally dependent on us_id, and if not, identify the cases that fail that condition. This is the reason I wrote -funcdep-. See -ssc desc collapseunique-

I hope this is useful.
--David

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