BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jbear
Calcite | Level 5

Hello,

I have limited experience with hash objects and read a few articles, but still no luck in one problem I am trying to approach with hash objects.

The data:

Table_A to load in hash table (where Orig_Code is hash key):

Orig_CodeNew_Code
ABBN
TYYX
UOUO
PEPE
MKLX
CCWQ
TTTT
JUJU
OVFZ

Table_B to overwrite Orig_Code with New_Code values:

IDColor_DesOrig_CodeFiller_1Filler_2
0000001BlueCCXXXXXXYYYYYY
0000002RedTTXXXXXXYYYYYY
0000003RedOVXXXXXXYYYYYY
0000004GreenOVXXXXXXYYYYYY
0000005PurpleMKXXXXXXYYYYYY
0000006YellowTYXXXXXXYYYYYY

Table_C results after doing overwrite with hash objects:

IDColor_DesOrig_CodeFiller_1Filler_2
0000001BlueWQXXXXXXYYYYYY
0000002RedTTXXXXXXYYYYYY
0000003RedFZXXXXXXYYYYYY
0000004GreenFZXXXXXXYYYYYY
0000005PurpleLXXXXXXXYYYYYY
0000006YellowYXXXXXXXYYYYYY

Here is where I am in the code:

data Table_C (drop = Orig_Code New_Code);

length Orig_Code $4. New_Code $4.;

if _n_ = 1 then do;

declare hash tempHsh(dataset: 'Table_A');

  tempHsh.definekey('Orig_Code');

  tempHsh.defineData('New_Code');

  tempHsh.defineDone();

  call missing (Orig_Code,New_Code);

end;

set Table_B;

rc=tempHsh.find();

if rc = 0 then ******** lost in this section...

run;

Any tips....to solve this problem? I appreacite the help.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
slchen
Lapis Lazuli | Level 10

if rc=0 then orig_code=new_code;

View solution in original post

2 REPLIES 2
slchen
Lapis Lazuli | Level 10

if rc=0 then orig_code=new_code;

jbear
Calcite | Level 5

Cool! Thanks...

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 977 views
  • 0 likes
  • 2 in conversation