dataset 1 ID Date 1 01/13/2017 1 01/14/2017 1 01/15/2017 1 02/15/2018 2 01/13/2017 2 01/15/2017 2 02/15/2018 3 01/13/2017 3 01/15/2017 3 02/15/2018 dataset 2 ID level Date 1 A 01/01/1993 1 B 01/14/2017 1 C 12/17/2017 2 A 05/24/2017 3 A 11/11/2016 Want ID Date Level 1 01/13/2017 A 1 01/14/2017 B 1 01/15/2017 B 1 02/15/2018 C 2 01/13/2017 2 01/15/2017 2 02/15/2018 A 3 01/13/2017 A 3 01/15/2017 A 3 02/15/2018 A Hi there. I want to merge the dataset1 and dataset2 by id and date. For each ID, I want to add variable 'level' to dataset1 based on its last record (in dataset2) before the given date in dataset1. For example, for a given date 01/13/2017 in dateset1. I want the level variable to be 'A', since according to dataset2, the last record before 01/13/2017 is 'A' ( on 01/01/1993). Any help to achieve this in sas? Thanks
... View more