44 %macro mp_recursivejoin(base_ds=
55 create table &outds as
56 select 0 as level,&parentvar, &childvar
58 where &parentvar=&matchval;
59 %
if &sqlobs.=0 %then %
do;
60 %put NOTE: &sysmacroname: No match
for &parentvar=&matchval;
65 %
else %
if &iter>&maxiter %then %
return;
68 create table _data_ as
70 ,curr.&childvar as &parentvar
71 ,base_ds.&childvar as &childvar
73 left join &base_ds base_ds
74 on curr.&childvar=base_ds.&parentvar
75 where curr.level=%eval(&iter.-1)
76 & curr.&childvar is not
null;
77 %local append_ds; %let append_ds=&syslast;
78 %local obs; %let obs=&sqlobs;
79 insert into &outds select distinct * from &append_ds;
80 %
if &mdebug=0 %then drop table &append_ds;;
83 %mp_recursivejoin(iter=%eval(&iter.+1)
84 ,outds=&outds,parentvar=&parentvar