Announcement

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

  • Drop Duplicate based on Countries Variable

    Hello,

    I'm trying to delete duplicate year (appyear) in relation to countries code (code) (see attached). It'll be much better if there's a command that does it in a random way too, meaning not dropping duplicate years in a chronological order.

    Thank you for your assistance.
    Attached Files

  • #2
    Anass:
    you may want to consider something along the following lines:
    Code:
    set obs 4
    g id=1 in 1/2
    replace id=2 in 3/4
    bysort id: g time=_n
    bysort id: g wanted=1
    bysort id: g count=runiform()
    bysort id: egen x=max(count)
    keep if count==x
    list
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo Lazzaro Thank you for your input, I did run that command lines but it seems that it only left me with 3 observations from my previous 3 million. and I got the following remark "observation number out of range
      Observation number must be between 2,923,922 and 2,147,483,619.
      (Observation numbers are typed without commas.)"

      Do it have to tweak something in your command maybe use my variable names?

      Comment


      • #4
        Anass:
        yes, you have to tweak it according to your research need.
        With no example/excerp of your dataset (please, see the FAQ and -dataex-. Thanks) it is difficult (for me, at least) to provide more positive replies.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo Lazzaro Thanks will have a go and it and see if it works

          Comment

          Working...
          X