Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mm_getfoldermembers.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Returns all direct child members of a particular folder
4 @details Displays the children for a particular folder, in a similar fashion
5 to the viya counterpart (mv_getfoldermembers.sas)
6
7 Usage:
8
9 %mm_getfoldermembers(root=/, outds=rootfolders)
10
11 %mm_getfoldermembers(root=/User Folders/&sysuserid, outds=usercontent)
12
13 @param [in] root= the parent folder under which to return all contents
14 @param [out] outds= the dataset to create that contains the list of
15 directories
16 @param [in] mDebug= set to 1 to show debug messages in the log
17
18 <h4> Data Outputs </h4>
19
20 Example for `root=/`:
21
22 |metauri $17|metaname $256|metatype $32|
23 |---|---|---|
24 |A5XLSNXI.AA000001|Products |Folder|
25 |A5XLSNXI.AA000002|Shared Data |Folder|
26 |A5XLSNXI.AA000003|User Folders |Folder|
27 |A5XLSNXI.AA000004|System |Folder|
28 |A5XLSNXI.AA00003K|30.SASApps |Folder|
29 |A5XLSNXI.AA00006A|Public|Folder|
30
31 <h4> SAS Macros </h4>
32 @li mm_getfoldertree.sas
33 @li mf_getuniquefileref.sas
34 @li mf_getuniquelibref.sas
35
36 @version 9.4
37 @author Allan Bowe
38
39**/
40%macro mm_getfoldermembers(
41 root=
42 ,outds=work.mm_getfoldertree
43)/*/STORE SOURCE*/;
44
45%if "&root" = "/" %then %do;
46 %local fname1 fname2 fname3;
47 %let fname1=%mf_getuniquefileref();
48 %let fname2=%mf_getuniquefileref();
49 %let fname3=%mf_getuniquefileref();
50 data _null_ ;
51 file &fname1 ;
52 put '<GetMetadataObjects>' ;
53 put '<Reposid>$METAREPOSITORY</Reposid>' ;
54 put '<Type>Tree</Type>' ;
55 put '<NS>SAS</NS>' ;
56 put '<Flags>388</Flags>' ;
57 put '<Options>' ;
58 put '<XMLSelect search="Tree[SoftwareComponents/SoftwareComponent'@;
59 put '[@Name=''BIP Service'']]"/>';
60 put '</Options>' ;
61 put '</GetMetadataObjects>' ;
62 run ;
63 proc metadata in=&fname1 out=&fname2 verbose;run;
64
65 /* create an XML map to read the response */
66 data _null_;
67 file &fname3;
68 put '<SXLEMAP version="1.2" name="SASFolders">';
69 put '<TABLE name="SASFolders">';
70 put '<TABLE-PATH syntax="XPath">//Objects/Tree</TABLE-PATH>';
71 put '<COLUMN name="metauri">><LENGTH>17</LENGTH>';
72 put '<PATH syntax="XPath">//Objects/Tree/@Id</PATH></COLUMN>';
73 put '<COLUMN name="metaname"><LENGTH>256</LENGTH>>';
74 put '<PATH syntax="XPath">//Objects/Tree/@Name</PATH></COLUMN>';
75 put '</TABLE></SXLEMAP>';
76 run;
77 %local libref1;
78 %let libref1=%mf_getuniquelibref();
79 libname &libref1 xml xmlfileref=&fname2 xmlmap=&fname3;
80
81 data &outds;
82 length metatype $32;
83 retain metatype 'Folder';
84 set &libref1..sasfolders;
85 run;
86
87%end;
88%else %do;
89 %mm_getfoldertree(root=&root, outds=&outds,depth=1)
90 data &outds;
91 set &outds(rename=(name=metaname publictype=metatype));
92 keep metaname metauri metatype;
93 run;
94%end;
95
96%mend mm_getfoldermembers;