I’ve got two datasets, one is a subset of the other.
For example let’s say I have
Master table:
Name,status,date john,born,1-08-2011 frank,alive,1-08-2011 john,alive,1-09-2011 frank,alive,1-09-2011 frank,alive,1-10-2011 john,dead,1-11-2011 frank,alive,1-11-2011
Sub table
frank,alive,1-11-2011 john,dead,1-11-2011
I’d like to search the master table, for each person’s status, on whatever previous day we have a record for.
So my result table I’d like to have
frank,alive,1-10-2011 john,alive,1-09-2011 (since he didn't get a record entry on 1-10)
And then ideally, suppress / remove records where the persons status hasn’t changed.
You can do this in two passes.
The first pass would be to sort your data.
Once your dataset is sorted, you can use a data step to iterate through it and use the “first.” and “last.” metavariables.
Every time the data step iterates with “first.name” as true, it will clear your retain variables. Right before the end of a group of names, when “last.name” is true, it will set the variables back to what they were previously (if there was a previous row) and output the row.