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   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: duplicates tagged, but list is not limited to unique values
Date   Mon, 17 Apr 2006 13:14:07 +0100

Just to flesh out the issue here: -duplicates tag- 
tags all duplicates with the # of duplicates. 

-egen, tag()- just one of each group with 1 and the others with 0. 

You can blame me for introducing each use of the
word, and thus for the inconsistency in meaning. 

More positively, you should check out -duplicates
examples-. 

Nick 
[email protected] 

Clive Nicholas
 
> 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.

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