I have two SAS datasets. The first is relatively small and contains unique dates and the corresponding identifier:
date dateID 1jan90 10 2jan90 15 3jan90 20 ...
The second data set is very large and has two date variables:
dt1 dt2 1jan90 2jan90 3jan90 1jan90 ...
I need to map both dt1 and dateID to dateID , so the output will look like this:
id1 id2 10 15 20 10
Efficiency is very important here. I know how to use a hash object to make one match, so I could take one data step to match for dt1 and then another step for dt2 , but I would like to do both in one data step. How can I do that?
Here is how I would make a match only for dt1 :
data tbl3; if 0 then set tbl1 tbl2; if _n_=1 then do; declare hash dts(dataset:'work.tbl2'); dts.DefineKey('date'); dts.DefineData('dateid'); dts.DefineDone(); end; set tbl1; if dts.find(key:date)=0 then output; run;
source share