Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_recursivejoin.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_recursivejoin macro
4
5 <h4> SAS Macros </h4>
6 @li mp_recursivejoin.sas
7 @li mp_assert.sas
8
9**/
10
11data work.have;
12 p=1;c=2;output;
13 p=2;c=3;output;
14 p=2;c=4;output;
15 p=3;c=5;output;
16 p=6;c=7;output;
17 p=8;c=9;output;
18run;
19
20%mp_recursivejoin(base_ds=work.have,outds=work.want,matchval=1
21 ,parentvar=p,childvar=c)
22
23proc sql noprint;
24 select count(*) into: n_pairs from work.want
25 where (p=1 and c=2) or (p=2 and c=3) or (p=2 and c=4) or (p=3 and c=5);
26 select count(*) into: n_deep from work.want where c=5;
27quit;
28
29%mp_assert(
30 iftrue=(&n_pairs=4),
31 desc=Checking that every descendant of the parent is returned,
32 outds=work.test_results
33)
34
35%mp_assert(
36 iftrue=(&n_deep=1),
37 desc=Checking that the deepest child is reached,
38 outds=work.test_results
39)