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_Code | New_Code |
---|---|
AB | BN |
TY | YX |
UO | UO |
PE | PE |
MK | LX |
CC | WQ |
TT | TT |
JU | JU |
OV | FZ |
Table_B to overwrite Orig_Code with New_Code values:
ID | Color_Des | Orig_Code | Filler_1 | Filler_2 |
---|---|---|---|---|
0000001 | Blue | CC | XXXXXX | YYYYYY |
0000002 | Red | TT | XXXXXX | YYYYYY |
0000003 | Red | OV | XXXXXX | YYYYYY |
0000004 | Green | OV | XXXXXX | YYYYYY |
0000005 | Purple | MK | XXXXXX | YYYYYY |
0000006 | Yellow | TY | XXXXXX | YYYYYY |
Table_C results after doing overwrite with hash objects:
ID | Color_Des | Orig_Code | Filler_1 | Filler_2 |
---|---|---|---|---|
0000001 | Blue | WQ | XXXXXX | YYYYYY |
0000002 | Red | TT | XXXXXX | YYYYYY |
0000003 | Red | FZ | XXXXXX | YYYYYY |
0000004 | Green | FZ | XXXXXX | YYYYYY |
0000005 | Purple | LX | XXXXXX | YYYYYY |
0000006 | Yellow | YX | XXXXXX | YYYYYY |
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
if rc=0 then orig_code=new_code;
if rc=0 then orig_code=new_code;
Cool! Thanks...
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!
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.
Ready to level-up your skills? Choose your own adventure.