Announcement

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

  • Identifying unmerged observations by group

    Hi. In the data below, I have merged two datasets by a common code variable to have the variables Product, year, and merge. I want to identify if there are Product names and years that have no match. Basically a flag for a Product-year group within which there is no _merge==3 value at all. For example, in the data below, the last five observations of ACIPHEX in 2008 should be flagged. Any help will be much appreciated.


    Code:
    input str35 Product float year1 byte _merge
    "ACANYA"   2009 1
    "ACANYA"   2009 3
    "ACANYA"   2010 1
    "ACANYA"   2010 3
    "ACANYA"   2011 1
    "ACANYA"   2011 3
    "ACANYA"   2012 1
    "ACANYA"   2012 3
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 1
    "ACCOLATE" 2007 3
    "ACIPHEX"  2007 1
    "ACIPHEX"  2007 1
    "ACIPHEX"  2007 1
    "ACIPHEX"  2007 3
    "ACIPHEX"  2007 3
    "ACIPHEX"  2007 3
    "ACIPHEX"  2008 1
    "ACIPHEX"  2008 1
    "ACIPHEX"  2008 1
    "ACIPHEX"  2008 1
    "ACIPHEX"  2008 1

  • #2
    Perhaps this will start you in a useful direction.
    Code:
    egen wanted = min(_merge!=3), by(Product year1)

    Comment


    • #3
      Thanks, William. That worked perfectly as always

      Comment

      Working...
      X