Hash object to overwrite data in large table

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

Hash object to overwrite data in large table

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


Accepted Solutions
Solution
‎06-23-2014 04:08 PM
Super Contributor
Posts: 275

Re: Hash object to overwrite data in large table

if rc=0 then orig_code=new_code;

View solution in original post


All Replies
Solution
‎06-23-2014 04:08 PM
Super Contributor
Posts: 275

Re: Hash object to overwrite data in large table

if rc=0 then orig_code=new_code;

Contributor
Posts: 29

Re: Hash object to overwrite data in large table

Cool! Thanks...

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 183 views
  • 0 likes
  • 2 in conversation