13%let recursive_saved_obs=%sysfunc(getoption(obs,keyword));
14%let recursive_saved_firstobs=%sysfunc(getoption(firstobs,keyword));
15options obs=max firstobs=1;
26%mp_assertscope(SNAPSHOT)
27%mp_recursivejoin(base_ds=work.have,outds=work.want,matchval=1
28 ,parentvar=p,childvar=c)
29%mp_assertscope(COMPARE,
30 desc=Checking mp_recursivejoin recursive call does not leak scope,
31 outds=work.test_results
36 call missing(level,p,c);
40%mp_assertmodel(work.want,base=work.join_model,
41 desc=Checking mp_recursivejoin output model,
42 outds=work.test_results
46 select count(*) into: n_pairs from work.want
47 where (p=1 and c=2) or (p=2 and c=3) or (p=2 and c=4) or (p=3 and c=5);
48 select count(*) into: n_deep from work.want where c=5;
50 coalesce(sum(level=0 and p=1 and c=2),0),
51 coalesce(sum(level=1 and p=2 and c=3),0),
52 coalesce(sum(level=1 and p=2 and c=4),0),
53 coalesce(sum(level=2 and p=3 and c=5),0),
54 coalesce(sum(level=2 and p=4 and c=.),0),
55 coalesce(sum(level=3 and p=5 and c=.),0)
56 into :n_total, :n_root, :n_23, :n_24, :n_35, :n_leaf4, :n_leaf5
62 desc=Checking that every descendant of the parent is returned,
63 outds=work.test_results
68 desc=Checking that the deepest child is reached,
69 outds=work.test_results
73 iftrue=(&n_total=6 and &n_root=1 and &n_23=1 and &n_24=1
74 and &n_35=1 and &n_leaf4=1 and &n_leaf5=1),
75 desc=Checking exact mp_recursivejoin rows levels and leaves,
76 outds=work.test_results
79options &recursive_saved_obs &recursive_saved_firstobs;