Announcement

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

  • Delete observations with older date within one year

    Dear Statalists,

    my data set looks like this:

    Meeting Date Year Company Attending Person
    25may2011 2011 A Bob
    25may2011 2011 A John
    25may2011 2011 A Peter
    25may2011 2011 A Seth
    25may2011 2011 A Marina
    25may2011 2011 A Rachel
    14nov2011 2011 A Bob
    14nov2011 2011 A John
    14nov2011 2011 A Peter
    14nov2011 2011 A Seth
    14nov2011 2011 A Marina
    14nov2011 2011 A Rachel

    Of course there are many companies (about 2.000). Usually there is one meeting per company per year. Some companies had more than one meeting in a year. What I would like to do, is to delete all meetings that took place earlier in a year, if in that year more than one meeting took place. For my example above, that means deleting all observations with meeting date = 25may2011, but only for company A.
    Please help me out! Thanks!

  • #2
    Some guesswork needed here but

    Code:
    by company year (meetingdate) : keep if meetingdate == meetingdate[_N]
    may help.

    Comment


    • #3
      Thank you, Nick!
      Seems to work.

      Comment

      Working...
      X