Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: detecting repeated ID's
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: detecting repeated ID's
Date
Mon, 5 Aug 2013 20:04:36 +0000
David,
-bysort- is your friend. There are several ways to do this, some more elegant than others. Here is one possibility:
. bysort propertyID: gen seq=_n
. tab seq
The tabulation will tell you how many properties have at least 1, 2, 3,... sales. If you also want to know the exact number of sales for each property you can do:
. bysort propertyID: gen nsales=_N
. tab nsales if seq==1
To restrict the observations to those with multiples:
. bysort propertyID: keep if _N>1
Regards,
Joe Canner
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of David Jones
Sent: Monday, August 05, 2013 3:45 PM
To: [email protected]
Subject: st: detecting repeated ID's
Hi Statalist,
I have a dataset of property sales that has an identifier for the property ID. I want to know how many of the properties appear more than once and then from there I'd like to restrict the observations to only those that appear more than once (to see a change in sale value).
I've been doing some reading but so far haven't run across a way to do this very easily. Does anyone have any suggestions?
Thanks!
David
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/