Folks,
I have data which I'll need to update as I go along. It's payslip information where old data will have to be overwritten with amended records.
My unique identifier per row is called payslip_id and my unique identifier to identify which payslips records need to be amended is called
previous_payslip_id. previous_payslip_id will correspond to the value in payslip_id which needs to be overwritten. See below for an example;
So this person has for four records. So the information on record 3 needs to overwrite the records in record 2 and then subsequently the information in record 4 needs to overwrite the information from record 3 which is now in record 2. So after this person will only be left with two entries. The first one and the last.
Can anyone think of an efficient way to do this, as the example above can occur multiple times for an individual but the logic behind it is the same.
Post test data in the form of a datastep, and show what you want out. Pictures, attachments etc. are not useful. As such I will present a theory:
1) Reverse sort the data so that record 4 is first, then 3 then 2 then 1.
2) Retain last value using retain statement.
3) Replace actual value as needed.
4) Resort data back to original form.
For this, if you don't have identifiers which give the order, then you would need to assign an order variable.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.