Statalist


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

Re: st: testing -duplicates tag-


From   "Eva Poen" <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: testing -duplicates tag-
Date   Wed, 3 Sep 2008 17:42:15 +0100

Michael,

what do you mean by "don't show"? -duplicates tag- generates a
variable representing the number of _duplicates_. It is equal to one
in your example, meaning one duplicate:

. list foreign headroom trunk dup if trunk==8 & head==2

     +----------------------------------------+
     |  foreign   headroom   trunk   dup_ad~d |
     |----------------------------------------|
 20. | Domestic        2.0       8          1 |
 57. |  Foreign        2.0       8          1 |
     +----------------------------------------+

. duplicates report headroom trunk if trunk==8 & head==2

Duplicates in terms of headroom trunk

--------------------------------------
   copies | observations       surplus
----------+---------------------------
        2 |            2             1
--------------------------------------

If this is not what you want, please include more detail of what it is
that you want to achieve. In case you want to generate a running
counter for duplicates among your variables, try this:

. bysort head trunk: gen obsno = _n

. list foreign headroom trunk dup obsno if trunk==8

     +------------------------------------------------+
     |  foreign   headroom   trunk   dup_ad~d   obsno |
     |------------------------------------------------|
  3. | Domestic        1.5       8          0       1 |
  7. | Domestic        2.0       8          1       1 |
  8. |  Foreign        2.0       8          1       2 |
 19. |  Foreign        2.5       8          1       1 |
 20. |  Foreign        2.5       8          1       2 |
     +------------------------------------------------+


Hopes this helps,
Eva


2008/9/3 Michael McCulloch <mm@pinest.org>:
> Hello,
> I'm testing -duplicates tag-, and puzzled as to why it won't show the two
> observations where headroom==2.0 and trunk==8.
>
> clear
> sysuse auto
> list foreign headroom trunk if trunk==8
> duplicates tag headroom trunk, generate(dup_admission_id)
>
> --
>
> Best wishes,
> Michael McCulloch
>
>
>
> Pine Street Foundation
> 124 Pine St., San Anselmo, CA 94960-2674
> Tel:    (415) 407-1357
> Fax:    (415) 485-1065
> mcculloch@pinestreetfoundation.org
> www.pinestreetfoundation.org
*
*   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   |   What's new   |   Site index