Macros for SAS Application Developers
https://github.com/sasjs/core
mm_getdirectories.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Returns a dataset with the meta directory object for a physical path
4 @details Provide a file path to get matching directory objects, or leave
5 blank to return all directories. The Directory object is used to reference
6 a physical filepath (eg when registering a .sas program in a Stored process)
7
8 @param path= the physical path for which to return a meta Directory object
9 @param outds= the dataset to create that contains the list of directories
10 @param mDebug= set to 1 to show debug messages in the log
11
12 @returns outds dataset containing the following columns:
13 - directoryuri
14 - groupname
15 - groupdesc
16
17 @version 9.2
18 @author Allan Bowe
19
20**/
21
22%macro mm_getDirectories(
23 path=
24 ,outds=work.mm_getDirectories
25 ,mDebug=0
26)/*/STORE SOURCE*/;
27
28%local mD;
29%if &mDebug=1 %then %let mD=;
30%else %let mD=%str(*);
31%&mD.put Executing mm_getDirectories.sas;
32%&mD.put _local_;
33
34data &outds (keep=directoryuri name directoryname directorydesc );
35 length directoryuri name directoryname directorydesc $256;
36 call missing(of _all_);
37 __i+1;
38%if %length(&path)=0 %then %do;
39 do while
40 (metadata_getnobj("omsobj:Directory?@Id contains '.'",__i,directoryuri)>0);
41%end; %else %do;
42 do while(
43 metadata_getnobj("omsobj:Directory?@DirectoryName='&path'",__i,directoryuri)
44 >0
45 );
46%end;
47 __rc1=metadata_getattr(directoryuri, "Name", name);
48 __rc2=metadata_getattr(directoryuri, "DirectoryName", directoryname);
49 __rc3=metadata_getattr(directoryuri, "Desc", directorydesc);
50 &mD.putlog (_all_) (=);
51 drop __:;
52 __i+1;
53 if sum(of __rc1-__rc3)=0 then output;
54 end;
55run;
56
57%mend mm_getDirectories;