I've two data sets with patient drug claim date and administration date, I want to map the drug to administration date without duplication of administration date (i.e. one administration date should only be for one drug date) and the hierarchy is to match the admin date happening on the same day as drug date as it's more reliable. If there is no same days admin date then find the closest date but making sure already matched admin dates aren't used again.
Have:
Patient DrugDate
A 01/05/2017
A 01/18/2017
A 01/31/2017
A 02/28/2017
Patient AdminDate
A 01/31/2017
A 02/28/2017
Want:
Patient DrugDate AdminDate
A 01/05/2017
A 01/18/2017
A 01/31/2017 01/31/2017
A 02/28/2017 03/17/2017
Appreciate your help. Thanks