Hello, I am trying to merge two datasets based on a numeric Id and at the same time creating a match flag for them. I need all records from x1 data whereas only those records that match from x2. The code I am using is shown below. data matches nonmatches; merge x1(in=a) x2(in=b); by id; if a and b then id_flag = 'Y'; if a then output matches; else output nonmatches; run; While I try to look up the resulting nonmatches again in the datasets, I see a few ids that match but have not been merged or flagged. Could someone please tell me where I am going wrong or any other way to do this. Thank you in advance.
... View more