data merged_account_information;
set account1; /*first table you are merging*/
length gender $6.;
if _n_=1 then do;
declare hash h1(dataset:"account_gender"); /*data memorising information from (the other table you are merging with)*/
h1.defineKey("account_number"); /*define key to merge on*/
h1.defineData("gender"); /*define variable to bring across*/
h1.defineDone(); /*closes hash set*/
end;
rc = h1.find() ;
if rc = 0; /*match returns 0*/
drop rc;
run;
/*to keep files that don’t match type rc ne 0*/
The code above merges the data set account1 with the data set account_gender by account number, and brings across the gender of the owner of each account!
Generally it's a good idea to declare hash on the smaller of the two tables your merging, otherwise you could get system support giving you a call sometime after you've run it! Also don't forget to specify the length of the variable you're bringing across!
Enjoy! P.S....I own a dog!!