Macros for SAS Application Developers
https://github.com/sasjs/core
mp_deletefolder.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mp_deletefolder.sas macro
4 
5  <h4> SAS Macros </h4>
6  @li mp_deletefolder.sas
7  @li mf_mkdir.sas
8  @li mf_nobs.sas
9  @li mp_assert.sas
10  @li mp_dirlist.sas
11 
12 **/
13 
14 /**
15  * make a directory structure
16  */
17 
18 %let root=%sysfunc(pathname(work))/top;
19 %mf_mkdir(&root)
20 %mf_mkdir(&root/a)
21 %mf_mkdir(&root/b)
22 %mf_mkdir(&root/a/d)
23 %mf_mkdir(&root/a/e)
24 %mf_mkdir(&root/a/e/f)
25 data "&root/a/e/f/ds1.sas7bdat";
26  x=1;
27 run;
28 
29 %mp_dirlist(path=&root, outds=myTable, maxdepth=MAX)
30 
31 %mp_assert(
32  iftrue=(%mf_nobs(work.mytable)=6),
33  desc=Temp data successfully created,
34  outds=work.test_results
35 )
36 
37 %mp_deletefolder(&root/a)
38 
39 %mp_dirlist(path=&root, outds=work.myTable2, maxdepth=MAX)
40 
41 data _null_;
42  set work.mytable2;
43  putlog (_all_)(=);
44 run;
45 
46 %mp_assert(
47  iftrue=(%mf_nobs(work.mytable2)=1),
48  desc=Subfolder and contents successfully deleted,
49  outds=work.test_results
50 )