Hi, I have two data sources (one and two), Simple and straight forward/; id,year,month and day of a given visit. What I would like, is to merge the files by id AND match the dates (month,day,year) as close as possible, If it's a perfect match, that's easy. If it's within few days, I want to keep the closest date. SO if there are dates 2 and three days apart from another date I want to keep the one record that is 2 days apart. At the end, I want everything from both sources. I tried PROC SQL, full join,create a diff_Date, then using a having clause, I tried data step merges... If you think you can help, I'd appreciate it, Thank you!!!!! data one; input id day month year; datalines; 1 2 12 2003 1 18 12 2003 1 14 4 2004 1 7 5 2004 1 26 5 2004 1 3 6 2004 1 18 6 2004 1 23 6 2004 1 9 7 2004 1 23 7 2004 1 18 8 2004 1 20 8 2004 1 25 8 2004 1 20 9 2004 1 20 10 2004 1 29 10 2004 1 3 11 2004 1 28 11 2004 1 28 11 2004 1 11 12 2004 1 11 12 2004 1 24 12 2004 1 19 1 2005 1 9 2 2005 1 23 2 2005 1 5 5 2005 1 17 5 2005 1 18 5 2005 1 20 6 2005 1 7 7 2005 1 13 7 2005 1 16 8 2005 1 1 9 2005 1 1 9 2005 1 12 9 2005 1 16 9 2005 1 12 10 2005 1 9 11 2005 1 30 11 2005 1 30 11 2005 ; data two; input id day month year; datalines; 1 14 4 2004 1 7 5 2004 1 21 5 2004 1 18 6 2004 1 9 7 2004 1 23 7 2004 1 17 8 2004 1 18 10 2004 1 28 11 2004 1 29 11 2004 1 30 11 2004 1 1 12 2004 1 2 12 2004 1 3 12 2004 1 4 12 2004 1 12 12 2004 1 13 12 2004 1 14 12 2004 1 15 12 2004 ; data want; infile datalines missover; input id day month year day_2 month_2 year_2; datalines; 1 2 12 2003 1 18 12 2003 1 14 4 2004 14 4 2004 1 7 5 2004 7 5 2004 1 26 5 2004 21 5 2004 1 3 6 2004 1 18 6 2004 18 6 2004 1 23 6 2004 1 9 7 2004 9 7 2004 1 23 7 2004 23 7 2004 1 18 8 2004 17 8 2004 1 20 8 2004 1 25 8 2004 1 20 9 2004 1 20 10 2004 18 10 2004 1 29 10 2004 1 3 11 2004 1 28 11 2004 28 11 2004 1 28 11 2004 29 11 2004 1 30 11 2004 1 1 12 2004 1 2 12 2004 1 3 12 2004 1 4 12 2004 1 11 12 2004 12 12 2004 1 11 12 2004 13 12 2004 1 14 12 2004 1 15 12 2004 1 24 12 2004 1 19 1 2005 1 9 2 2005 1 23 2 2005 1 5 5 2005 1 17 5 2005 1 18 5 2005 1 20 6 2005 1 7 7 2005 1 13 7 2005 1 16 8 2005 1 1 9 2005 1 1 9 2005 1 12 9 2005 1 16 9 2005 1 12 10 2005 1 9 11 2005 1 30 11 2005 1 30 11 2005 ;
... View more