DATA Step, Macro, Functions and more

HASH Output

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

HASH Output

Here is my sample template. How can I output Matched and Unattached records by a key variable to a work.match and work.unmatch dataset ?  
 
DATA NAME; 
IF 0 THEN SET SMALL_DATA_SET; 
if _N_ = 1 then do;  
declare hash HASH_NAME(dataset: "SMALL_DATA_SET", multidata: 'y'); 
HASH_NAME.defineKEY("YOUR_KEY_VARIABLE"); 
HASH_NAME.defineData (ALL:'YES'); 
HASH_NAME.defineDone();
END; 
set BIG_DATA_SET; 
IF HASH_NAME.FIND(KEY:YOUR_KEY_VARIABLE) = 0 THEN OUTPUT; 
RUN;

Accepted Solutions
Solution
‎06-02-2017 02:55 AM
PROC Star
Posts: 1,760

Re: HASH Output

Like this?


data MATCHED UNMATCHED; 
  if 0 then set SMALL_DATA_SET; 
  if _N_ = 1 then do;  
    declare hash HASH_NAME(dataset: "SMALL_DATA_SET", multidata: 'y'); 
    HASH_NAME.defineKey("YOUR_KEY_VARIABLE"); 
    HASH_NAME.defineData (ALL:'YES'); 
    HASH_NAME.defineDone();
  end; 
  set BIG_DATA_SET; 
  if HASH_NAME.find()=0 then output MATCHED; 
  else output UNMATCHED; 
run;

Do you really need definedata() ?

 

View solution in original post


All Replies
Solution
‎06-02-2017 02:55 AM
PROC Star
Posts: 1,760

Re: HASH Output

Like this?


data MATCHED UNMATCHED; 
  if 0 then set SMALL_DATA_SET; 
  if _N_ = 1 then do;  
    declare hash HASH_NAME(dataset: "SMALL_DATA_SET", multidata: 'y'); 
    HASH_NAME.defineKey("YOUR_KEY_VARIABLE"); 
    HASH_NAME.defineData (ALL:'YES'); 
    HASH_NAME.defineDone();
  end; 
  set BIG_DATA_SET; 
  if HASH_NAME.find()=0 then output MATCHED; 
  else output UNMATCHED; 
run;

Do you really need definedata() ?

 

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 113 views
  • 0 likes
  • 2 in conversation