Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_dirlist.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_dirlist.sas macro
4
5 <h4> SAS Macros </h4>
6 @li mf_nobs.sas
7 @li mf_mkdir.sas
8 @li mp_dirlist.sas
9 @li mp_assert.sas
10
11**/
12
13/**
14 * make a directory structure
15 */
16
17%let root=%sysfunc(pathname(work))/top;
18%mf_mkdir(&root)
19%mf_mkdir(&root/a)
20%mf_mkdir(&root/b)
21%mf_mkdir(&root/a/d)
22%mf_mkdir(&root/a/e)
23%mf_mkdir(&root/a/e/f)
24libname test "&root/a/e/f";
25data test.ds1;
26 x=1;
27run;
28
29%mp_dirlist(path=&root, outds=myTable, maxdepth=MAX)
30
31%mp_assert(
32 iftrue=(%mf_nobs(work.mytable)=6),
33 desc=All levels returned,
34 outds=work.test_results
35)
36
37%mp_dirlist(path=&root, outds=myTable2, maxdepth=2)
38
39%mp_assert(
40 iftrue=(%mf_nobs(work.mytable2)=5),
41 desc=Top two levels returned,
42 outds=work.test_results
43)
44
45%mp_dirlist(path=&root, outds=work.myTable3, maxdepth=0)
46
47%mp_assert(
48 iftrue=(%mf_nobs(work.mytable3)=2),
49 desc=Top level returned,
50 outds=work.test_results
51)
52
53%mp_dirlist(path=&root/b, outds=work.myTable4)
54%mp_assert(
55 iftrue=(%mf_nobs(work.mytable4)=0),
56 desc=Empty table for empty directory,
57 outds=work.test_results
58)
59
60%mp_dirlist(path=&root/notexisting, outds=work.myTable5)
61%mp_assert(
62 iftrue=(%mf_nobs(work.mytable5)=0),
63 desc=Empty table for non-existing directory,
64 outds=work.test_results
65)