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...

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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