Announcement

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

  • duplicates drop

    Hi all,
    I have a dataset with 52,000 observation in which I have a variable called "edate" and another variable called "station".

    I ran isid command and the output give me an error:
    variables station edate do not uniquely identify the observations

    after this, I ran .duplicates list station edate:

    +----------------------------------------------+
    | group: obs: station edate |
    |----------------------------------------------|
    | 1 4542 1019 13jun2012 |
    | 1 4627 1019 13jun2012 |
    | 2 5657 1019 16jun2012 |
    | 2 5744 1019 16jun2012 |
    | 3 37923 1019 01sep2012 |
    |------------------------------------------------|
    | 3 38022 1019 01sep2012 |
    | 4 38926 1019 03sep2012 |
    | 4 39028 1019 03sep2012 |
    | 5 19382 1059 17jul2012 |
    | 5 19620 1059 17jul2012 |
    |------------------------------------------------|
    | 6 26169 1059 04aug2012 |
    | 6 26377 1059 04aug2012 |
    | 7 33291 1059 23aug2012 |
    | 7 33345 1059 23aug2012 |
    | 8 33868 1059 24aug2012 |
    |------------------------------------------------|
    | 8 33921 1059 24aug2012 |
    | 8 33935 1059 24aug2012 |
    | 9 37869 1059 01sep2012 |
    | 9 38209 1059 01sep2012 |
    | 10 39411 1059 04sep2012 |
    |------------------------------------------------|
    | 10 39676 1059 04sep2012 |

    now, for example, station 1019 is repeated twice for some days and I want to keep only one of these observations.

    thanks for your help and I apologize for my English

  • #2
    Code:
    duplicates drop station edate

    Comment


    • #3
      Hi Mario,

      how about merging the values of "obs" and "station edate" to one variable and then dropping the duplicates?
      You would have to be aware of the likely type mismatch of the variables though.

      Code:
      tostring obs, gen(string_obs)
      gen newnew = "new_obs" & "station edate"
      duplicates drop newnew
      I am also new to Stata and just an occasional user, but may this helps.

      With kind regards,
      Torben

      Comment


      • #4
        ok.
        I tried and work well.
        really thanks.

        Comment


        • #5
          #3 perhaps crossed with #2 but note that the combination of variables is quite unnecessary and the syntax in #3 looks unlikely to work at all.

          Comment

          Working...
          X