I have two data sets, setA and setB. Both have ID column. I want to add one more column in setA, called "In_setB", that when the ID is found in set B, In_setB = "Yes"; when there is no such a match, In_setB = "No".
The only way I can do it, is using merge and IN options, like codes below. It works, but I wonder if others have simpler solutions. Thank you.
data setA;
input ID $ amount;
datalines;
001 150
002 200
003 100
004 160
005 180
006 220
;
run;
data setB;
input ID $ amount;
datalines;
002 230
004 180
005 200
007 190
009 210
;
run;
/* I want to have want like this:
ID Amount In_setB
001 150 No
002 200 Yes
003 100 No
004 160 Yes
005 180 Yes
006 220 No
*/
data want;
merge setA(IN=A) setB(IN=B);
by ID;
If A and B then In_setB = "Yes";
if A and not B then In_setB = "No";
If not A and B then delete;
run;
... View more