Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Dropping Duplicates that Aren't Exactly Duplicates


From   Lisa Chavez <lchavez@law.berkeley.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Dropping Duplicates that Aren't Exactly Duplicates
Date   Wed, 02 Nov 2011 11:06:08 -0700

I have data in long file format that has three variables: id, arrdate and violation.

Below is an example of a person who has three arrest events (I have separated them with lines).

Looking at the first two arrest dates (11mar2004 and 13jan2005) you see that each arrest has three violations and they are exactly the same.

I have lots of examples like this one; in all instances I want to drop the last arrest event where this duplication occurs.

In the case below, I would want to drop all rows associated with the 13jan2005 arrest event.

I'd appreciate any help you can offer.

Thanks!

Lisa

+----------------------------------------------------------------------------------------+
id arrdate violation
----------------------------------------------------------------------------------------
A0000518 11mar2004 Cocaine-Possess Possess Cocaine A0000518 11mar2004 Nonmoving Traffic Viol Drive While Lic Susp Habitual Offender A0000518 11mar2004 Traffic Offense Dui Alcohol Or Drugs 1St Off
----------------------------------------------------------------------------------------
A0000518 13jan2005 Cocaine-Possess Possess Cocaine A0000518 13jan2005 Nonmoving Traffic Viol Drive While Lic Susp Habitual Offender A0000518 13jan2005 Traffic Offense Dui Alcohol Or Drugs 1St Off
----------------------------------------------------------------------------------------
A0000518 27feb2009 Hallucinogen-Sell Schedule Ii
+----------------------------------------------------------------------------------------+



--
Lisa Chavez, Ph.D.
Senior Research Associate
Chief Justice Earl Warren Institute on Law and Social Policy
Berkeley Law School

2850 Telegraph Ave. Suite 500
Berkeley, CA 94705-7220
Tel 510-642-8567
Fax 510-643-7095
Email:  lchavez@law.berkeley.edu

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index