Statalist The Stata Listserver


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

Re: st: duplicates tagged, but list is not limited to unique values


From   "Clive Nicholas" <Clive.Nicholas@newcastle.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: duplicates tagged, but list is not limited to unique values
Date   Sun, 16 Apr 2006 08:32:35 +0100 (BST)

Michael McCulloch wrote:

> I would like to tag and display duplicate values of 4 variables. This
> works
> if I DROP duplicates, but not if I TAG them. I'd like to be able to keep
> my
> data! Am I doing the DUPLICATES incorrectly, or the LIST?
>
> ***TAG METHOD
> .sort var1 var2 var3 var4
> .duplicates tag var1 var2 var3 var4, generate(tag)
> .list var1 var2 var3 var4 tag if tag, noobs
>
> var1    var2    var3    var4            tag
> 3       no      yes     .8571423        52
> 3       no      yes     .8571423        52
> 3       no      yes     .8571423        52
> 3       no      yes     .8571423        52
> 3       no      yes     .8571423        52
>
> ***DROP METHOD
> .duplicates drop var1   var2    var3    var4, force
> .list var1      var2    var3    var4 tag if &tag, clean noobs
>
> var1    var2    var3    var4            tag
> 3       no      yes     .8571423        52
> 3       yes     yes     .5784351        12
> 4       no      yes     .7797139        70
> 5       no      yes     .6761742        21

I would do the following (let's call the tag variable "marker"):

. sort var1 var2 var3 var4
. egen marker=tag(var1 var2 var3 var4)

That should work. See -whelp egen- for more.

CLIVE NICHOLAS        |t: 0(044)7903 397793
Politics              |e: clive.nicholas@ncl.ac.uk
Newcastle University  |http://www.ncl.ac.uk/geps

Whereever you go and whatever you do, just remember this. No matter how
many like you, admire you, love you or adore you, the number of people
turning up to your funeral will be largely determined by local weather
conditions.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index