I have two data sets (data below) and I am trying to merge the data together using proc sql code below. When I merge the two tables I get all of the dates from Id 3 and only the review dates for ID 1 and 2. I have tried to join the two tables using left, right, inner and full join and it seems as if I am getting the same results. What I would like to do is merge by ID and keep all of the dates for each ID.
Can someone assist me with this please?
data test1; infile datalines delimiter = ','; input ID START:mmddyy10. REVIEWCOMPLETE: mmddyy10. HEALTHDATE:mmddyy10. HEALTHDATEEND:mmddyy10. END: mmddyy10. CERTIFYDATE: mmddyy10.; format START REVIEWCOMPLETE HEALTHDATE HEALTHDATEEND END CERTIFYDATE mmddyy10. ; datalines; 1, , , , , , , 2, , , , , , , 3,01/16/2019, 01/23/2019, 01/26/2019, 01/26/2019, 01/26/2019,01/26/2019, ; Run;
data test2; infile datalines delimiter = ','; input ID START:mmddyy10. REVIEW:mmddyy10. REVIEWCOMPLETE: mmddyy10. HEALTHDATE:mmddyy10. HEALTHDATEEND:mmddyy10. END: mmddyy10. CERTIFYDATE: mmddyy10.; format START REVIEW REVIEWCOMPLETE HEALTHDATE HEALTHDATEEND END CERTIFYDATE mmddyy10. ; datalines; 1,01/17/2020,01/29/2020,01/30/2020, , , , , 2,01/10/2020,01/24/2020, , , , , , 3, , , , , , , , ; Run;
proc sql; create table table3 as select * from test1 as a inner join test2 as b on a.id = b.id; quit;
... View more