01-14-2014 01:46 PM
I am learning hash objects ,when I was working on the below scenario,it is giving as specified below.please clarify.
I have two data sets ,I am assuming that one is bigger one and one is smaller one.
the smaller data(data1) set consists of following data.
the bigger one(master) data set consists of following data.
Connection_id credit_teamid unit_desc group_code
length connection_id 10;
length credit_team_id unit_desc group_code $20;
if _n_=1 then do;
declare hash first_HT(dataset:"master");
if search=0 then output;
Here I'm getting the output like this
Even though master data set consists of same connection id and credit team id's more than once,small data set is not merging with all the connection and credit team id's in the master data set.
It is only merging with first occurance(first.) of the connection id and credit team id's of the master data set.
01-14-2014 08:41 PM
For loading "master" into a hash you would need "multidata" with the keys you've chosen. You then would also need to iterate through the groups with the same key as shown here:
But actually for what I believe you're trying to achieve it would be much better to load the small data set into a hash. As the key variables exist in both "master" and "data1" you don't need to define the variables for the hash if "setting" master before the hash definition.
Code as below should do (not tested):
DATA Hash_sample (drop=_;
if _n_=1 then
declare hash first_HT(dataset:"data1");
if first_ht.find()=0 then output;