Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
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 [in] path= Physical path for which to return a meta Directory object
9 @param [out] outds= (work.mm_getdirectories)
10 the dataset to create that contains the list of directories
11 @param [in] mDebug= (0) set to 1 to show debug messages in the log
12
13 @returns outds dataset containing the following columns:
14 - directoryuri
15 - groupname
16 - groupdesc
17
18 @version 9.2
19 @author Allan Bowe
20
21**/
22
23%macro mm_getDirectories(
24 path=
25 ,outds=work.mm_getDirectories
26 ,mDebug=0
27)/*/STORE SOURCE*/;
28
29%local mD;
30%if &mDebug=1 %then %let mD=;
31%else %let mD=%str(*);
32%&mD.put Executing mm_getDirectories.sas;
33%&mD.put _local_;
34
35data &outds (keep=directoryuri name directoryname directorydesc );
36 length directoryuri name directoryname directorydesc $256;
37 call missing(of _all_);
38 __i+1;
39%if %length(&path)=0 %then %do;
40 do while
41 (metadata_getnobj("omsobj:Directory?@Id contains '.'",__i,directoryuri)>0);
42%end; %else %do;
43 do while(
44 metadata_getnobj("omsobj:Directory?@DirectoryName='&path'",__i,directoryuri)
45 >0
46 );
47%end;
48 __rc1=metadata_getattr(directoryuri, "Name", name);
49 __rc2=metadata_getattr(directoryuri, "DirectoryName", directoryname);
50 __rc3=metadata_getattr(directoryuri, "Desc", directorydesc);
51 &mD.putlog (_all_) (=);
52 drop __:;
53 __i+1;
54 if sum(of __rc1-__rc3)=0 then output;
55 end;
56run;
57
58%mend mm_getDirectories;