Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dropping dupliate dates by person

    Hello, I am working with claims data and trying to drop duplicate dates by person in order to identify a single date for a group of claims
    I have tried to generate an tag id by date and drop based on 0s but, so far, I am unable to get this to work. Would sure appreciate help with this. Thanks. Jake


    I have also tried the following:

    sort unique_person_id pert_service_start_dt
    capture drop dup
    quietly by pert_service_start_dt (unique_person_id): gen dup = cond(_N==1,0,_n)

    clear
    input long unique_person_id str10 pert_service_start_dt
    1 "2013-07-12"
    1 "2014-04-28"
    1 "2014-10-17"
    1 "2014-12-05"
    1 "2014-12-22"
    1 "2015-02-23"
    1 "2015-03-05"
    1 "2015-03-10"
    1 "2015-04-28"
    1 "2015-05-16"
    1 "2015-07-19"
    1 "2015-09-27"
    1 "2015-09-28"
    1 "2015-09-28"
    1 "2015-12-01"
    2 "2013-07-20"
    2 "2013-10-14"
    2 "2013-10-14"
    2 "2013-10-14"
    2 "2013-10-14"
    2 "2013-10-14"
    2 "2013-11-03"
    2 "2013-11-03"
    2 "2013-11-22"
    2 "2013-11-24"
    2 "2013-11-24"
    2 "2013-11-24"
    2 "2013-11-24"
    2 "2013-11-24"
    2 "2013-12-11"
    2 "2013-12-11"
    2 "2013-12-14"
    2 "2013-12-14"
    2 "2013-12-18"
    2 "2013-12-28"
    2 "2014-02-07"
    2 "2014-03-03"
    2 "2014-03-20"
    2 "2014-03-31"
    2 "2014-03-31"
    2 "2014-03-31"
    2 "2014-03-31"
    2 "2014-04-06"
    2 "2014-04-17"
    2 "2014-04-17"
    2 "2014-04-20"
    2 "2014-04-20"
    2 "2014-04-20"
    2 "2014-04-20"
    2 "2014-04-20"
    2 "2014-04-30"
    2 "2014-04-30"
    2 "2014-04-30"
    2 "2014-04-30"
    2 "2014-04-30"
    2 "2014-05-01"
    2 "2014-05-01"
    2 "2014-05-01"
    2 "2014-05-01"
    2 "2014-05-01"
    2 "2014-05-02"
    2 "2014-05-02"
    2 "2014-05-02"
    2 "2014-07-03"
    2 "2014-07-03"
    2 "2014-07-03"
    2 "2014-07-19"
    2 "2014-07-29"
    2 "2014-07-30"
    2 "2014-07-30"
    2 "2014-08-17"
    2 "2014-09-14"
    2 "2014-09-22"
    2 "2014-09-22"
    2 "2014-09-22"
    2 "2014-09-27"
    2 "2014-10-02"
    2 "2014-10-02"
    2 "2014-10-07"
    2 "2014-10-21"
    2 "2014-10-21"
    2 "2014-10-21"
    2 "2014-10-21"
    2 "2014-10-24"
    2 "2014-10-24"
    2 "2014-10-24"
    2 "2014-10-24"
    2 "2014-10-29"
    2 "2014-10-29"
    2 "2014-10-29"
    2 "2014-10-29"
    2 "2014-10-30"
    2 "2014-12-05"
    2 "2014-12-05"
    2 "2014-12-12"
    2 "2014-12-12"
    2 "2014-12-12"
    2 "2014-12-31"
    2 "2015-01-26"
    2 "2015-01-26"
    end
    [/CODE]

  • #2
    Can you say a bit more how the tagging strategy failed?

    Is this not what you want?

    Code:
    . sort unique pert
    
    . egen tag = tag(unique pert)
    
    . keep if tag
    (49 observations deleted)
    
    . list
    
         +-----------------------------+
         | unique~d   pert_ser~t   tag |
         |-----------------------------|
      1. |        1   2013-07-12     1 |
      2. |        1   2014-04-28     1 |
      3. |        1   2014-10-17     1 |
      4. |        1   2014-12-05     1 |
      5. |        1   2014-12-22     1 |
         |-----------------------------|
      6. |        1   2015-02-23     1 |
      7. |        1   2015-03-05     1 |
      8. |        1   2015-03-10     1 |
      9. |        1   2015-04-28     1 |
     10. |        1   2015-05-16     1 |
         |-----------------------------|
     11. |        1   2015-07-19     1 |
     12. |        1   2015-09-27     1 |
     13. |        1   2015-09-28     1 |
     14. |        1   2015-12-01     1 |
     15. |        2   2013-07-20     1 |
         |-----------------------------|
     16. |        2   2013-10-14     1 |
     17. |        2   2013-11-03     1 |
     18. |        2   2013-11-22     1 |
     19. |        2   2013-11-24     1 |
     20. |        2   2013-12-11     1 |
         |-----------------------------|
     21. |        2   2013-12-14     1 |
     22. |        2   2013-12-18     1 |
     23. |        2   2013-12-28     1 |
     24. |        2   2014-02-07     1 |
     25. |        2   2014-03-03     1 |
         |-----------------------------|
     26. |        2   2014-03-20     1 |
     27. |        2   2014-03-31     1 |
     28. |        2   2014-04-06     1 |
     29. |        2   2014-04-17     1 |
     30. |        2   2014-04-20     1 |
         |-----------------------------|
     31. |        2   2014-04-30     1 |
     32. |        2   2014-05-01     1 |
     33. |        2   2014-05-02     1 |
     34. |        2   2014-07-03     1 |
     35. |        2   2014-07-19     1 |
         |-----------------------------|
     36. |        2   2014-07-29     1 |
     37. |        2   2014-07-30     1 |
     38. |        2   2014-08-17     1 |
     39. |        2   2014-09-14     1 |
     40. |        2   2014-09-22     1 |
         |-----------------------------|
     41. |        2   2014-09-27     1 |
     42. |        2   2014-10-02     1 |
     43. |        2   2014-10-07     1 |
     44. |        2   2014-10-21     1 |
     45. |        2   2014-10-24     1 |
         |-----------------------------|
     46. |        2   2014-10-29     1 |
     47. |        2   2014-10-30     1 |
     48. |        2   2014-12-05     1 |
     49. |        2   2014-12-12     1 |
     50. |        2   2014-12-31     1 |
         |-----------------------------|
     51. |        2   2015-01-26     1 |
         +-----------------------------+
    
    .

    Comment


    • #3
      Exactly. Thanks.

      Comment


      • #4
        You are welcome.

        egen, tag

        selects one observation in the group identified by the varlist within parenthesis in tag().

        And btw my sorting in

        Code:
         
         . sort unique pert
        is redundant, no need to sort like that.


        Comment

        Working...
        X