I have two SAS datasets of following type
Dataset1, D1 is as follows
ID Date Amount
x1 10/12/2015 100
x2 200
x2 150
x3 10/10/2014 90
x4 60
Dataset, D2 is of the form
ID Date
x2 10/12/2016
x4 1/1/2016
Dataset D1 can have duplicate values of ID. Dataset D2 has only unique values of ID. Further, D2 consists of only IDs in Dataset D1 which has missing values of variable date (x2 and x4 have date missing in D1). I want to merge D1 with D2 such that the output is as follows
ID Date Amount
x1 10/12/2015 100
x2 10/12/2016 200
x2 10/12/2016 150
x3 10/10/2014 90
x4 1/1/2016 60
Is this doable without using proc sql in SAS. Can I use merge?
I tried using the following but to no use (and it should not work either because D1 has duplicate IDs)
data x;
merge D1 (in=in1) D2(in=in2);
by ID;
if in1;
run;