I need a function (using base SAS or RStudio) that will enable me to determine the ID numbers as of a certain date and the original (root) ID numbers as of the start date. The dataset includes the old ID, the new ID, and the date the ID changed. Example data:
OldID | NewID | Change Date |
---|---|---|
1 | 2 | 1/1/10 |
10 | 11 | 1/1/10 |
2 | 3 | 7/1/10 |
3 | 4 | 7/10/10 |
11 | 12 | 8/1/10 |
I need to know the ID numbers as of 7/15/10 and the original (root) ID (as of 1/1/10). The output should look like this:
OrigID | LastID |
---|---|
1 | 4 |
10 | 11 |
I will then need a flag that will help me count the number of OrigID's that changed over the given time interval (in this case, 1/1/10 to 7/15/10). I need to do similar counts for multiple dates after 7/15/10 as well.
Is there a function in base SAS or RStudio that can do this?
It doesn't appear that the functions in SAS/R I researched (hierarchic loggers, synchronous tracking, sequence tracking functions) will work (e.g., logger, lumberjack, log4r, validate, futile.logger)