BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
EinarRoed
Pyrite | Level 9

We've got a reusable SAS-script that runs 1 time per source table. It distributes each table to a corresponding target table. Some source tables have 1 primary key, others have 2-3. But we want to set 1 key per table (primarily because the reusable script can be simplified when the keys don't differ from table to table).

 

I've used the primary keys from the source tables to create 1 unique hex value per row. Example value: "C0EA54AAB21573E07D46E9BB9E9B1C73".

 

Ideally we wanted to change the hex into a numeric field (faster joins). But as Tom said: "The MD5() function returns 128 bits. So at 8 bits per byte that is 16 bytes. That is waaaaaay too many to convert into a single number. So leave it as character and use the $HEX32 format to display it."

 

Proper naming standard is important to us, and I'm stumped on what to call the field. Considered calling it a Retained Key (w/RK-suffix) because it's set based on primary keys from the source tables. But RKs are only supposed to be integers I think. And it seems wrong to call it a Primary Key (w/PK-suffix), because each target table has a composite key that will consist of this hex-variable and a date variable -- so the hex isn't unique by itself.

 

I'm thankful for any naming advice. 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @EinarRoed,

 

I have seen "surrogate key" and variables with suffix _SK for exactly this type of keys. See Paul Dorfman, Don Henderson: Data Management Solutions Using SAS® Hash Table Operations: A Business ..., e.g., section 11.4.2 MD5 Key Reduction in Sample Data.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @EinarRoed,

 

I have seen "surrogate key" and variables with suffix _SK for exactly this type of keys. See Paul Dorfman, Don Henderson: Data Management Solutions Using SAS® Hash Table Operations: A Business ..., e.g., section 11.4.2 MD5 Key Reduction in Sample Data.

EinarRoed
Pyrite | Level 9
Thanks for the good suggestion, we'll likely go for SK.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 916 views
  • 1 like
  • 2 in conversation