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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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