BookmarkSubscribeRSS Feed
docctong
Fluorite | Level 6

Hello All,

 

I have two different datasets that provide info on claim amount paid by two different sources.  Each  set includes the claimant name, the date of incident, and the amount paid.  So let's say Name1, Date1, and Paid 1 are fields in Set #1, and Name2, Date2, and Paid2 are fields in Set #2.  Each of the two sets includes other fields that are not totally identical.  What I need to do is to find out those claimants who are in both sets of data, i.e., Name1=Name2, and were injured on the same date and so Date1=Date2, and then create a new field named as TotalPaid = Paid1+Paid2.  That is, I need to find out the total amount of paid for each claimant from both sources.  For those claimants exist only in one and not both sets, then TotalPaid=0.  The rationale of using these two conditions to set up the new field is because it is not likely that two individuals who got injured on the same date will have the same name.  How can I do that?  Thanks for helping.  

1 REPLY 1
Reeza
Super User

Post sample data and expected output - not real data because you obviously can't release that, but some data that's similar to what you have, especially if you want code. 

 

Things that are unclear in your current question:

  • Do you want the final dataset to have all people, only people in first dataset, only people in second, only people in both?
  • Are the formats/type the same between the two for merges - they have to be.
  • When I've worked with medical data and we also used a window, not a specific date=date, because a lot of times a wait in an ER can stretch over midnight which means dates for things may be off by at minimum one date. If this isn't a concern feel free to ignore this comment 🙂

Otherwise this is most likely more easy to accomplish in SQL though a data step merge is also possible. 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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