BookmarkSubscribeRSS Feed
Sean_OConnor
Fluorite | Level 6

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;

 

example.png

 

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. 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 521 views
  • 0 likes
  • 2 in conversation