BookmarkSubscribeRSS Feed
WLP165
Calcite | Level 5

Hello,

I am a novice SAS user.  I am trying to calculate simple numerical differences (current variable value minus prior variable value) for certain variables common to two separate SAS datasets.  However, in this case, the key field values in each dataset that I have to use as a "link" between the two intentionally differ in value.  For example, the key value used in dataset one might be 311320 and it's key value counterpart in the other is 311351.  As a result, the numerical differences calculated have to be based on using the variable values for these differing keys in each dataset (in others words, 311351 values minus 311320 values).  I'm a little stumped and need help.

William

4 REPLIES 4
Reeza
Super User

How do you know which records go with which then?

What's the logic behind the matches..

WLP165
Calcite | Level 5

I have a crosswalk of these six-digit codes (there are ten pairs of these currently) that show the older code crosswalked to the newer one (such as old code 311320 crosswalked to new code 311351, 311330 to 311352, etc).  Normally, this is not the case with this particular product as difference calculations are simply calculated from matching codes which is a bit easier and more straightforward (311320 to 311320, 311330 to 311330, etc).

However, our program revises these codes once every five years so a situation like the above may come up.

art297
Opal | Level 21

Seeing your code and examples of the two datasets would help.  You can easily recode values with a simple combination of it then else statements.

Spacetime
Obsidian | Level 7

It sounds like you could make a custom format to put your OLD_KEY into your NEW_KEY values.  Then just do a join from the NEW_KEY?  It has to know how to join the records.  I would try to use PROC FORMAT to do it.  If you put it into your new format it will translate the old key to the new.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1013 views
  • 0 likes
  • 4 in conversation