1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
data a ;
input key adata adata2 ;
cards ;
1 1 2
1 1 3
2 2 5
8 7 5
9 5 4
;
run ;
data b ;
input key bdata ;
cards ;
1 11
1 12
3 31
4 4
6 61
6 62
6 63
7 7
;
run ;
proc sql;
create table resultat_sql as select a.*,b.bdata
from a left join b on a.key=b.key;
quit;
data resultat_hash;
if 0 then set a ;
dcl hash b (dataset: "a", multidata: "y",ordered:'y') ;
b.definekey ("key") ;
b.definedata (all:'y') ;
b.definedone () ;
do until(eof);
set b end=eof;
rc=b.find();
if rc ne 0 then do;
call missing(bdata);
output;
end;
else
do while(rc eq 0);
output;
rc=b.find_next();
end;
end;
stop;
run; |
Partager