CORE
mm_getlibs.sas
Go to the documentation of this file.
1 
29 %macro mm_getlibs(
30  outds=work.mm_getLibs
31  );
32 
33 /*
34  flags:
35 
36  OMI_SUCCINCT (2048) Do not return attributes with null values.
37  OMI_GET_METADATA (256) Executes a GetMetadata call for each object that
38  is returned by the GetMetadataObjects method.
39  OMI_ALL_SIMPLE (8) Gets all of the attributes of the requested object.
40 */
41 data _null_;
42  flags=2048+256+8;
43  call symputx('flags',flags,'l');
44 run;
45 
46 * use a temporary fileref to hold the response;
47 filename response temp;
48 /* get list of libraries */
49 proc metadata in=
50  '<GetMetadataObjects>
51  <Reposid>$METAREPOSITORY</Reposid>
52  <Type>SASLibrary</Type>
53  <Objects/>
54  <NS>SAS</NS>
55  <Flags>&flags</Flags>
56  <Options/>
57  </GetMetadataObjects>'
58  out=response;
59 run;
60 
61 /* write the response to the log for debugging */
62 data _null_;
63  infile response lrecl=32767;
64  input;
65  put _infile_;
66 run;
67 
68 /* create an XML map to read the response */
69 filename sxlemap temp;
70 data _null_;
71  file sxlemap;
72  put '<SXLEMAP version="1.2" name="SASLibrary">';
73  put '<TABLE name="SASLibrary">';
74  put '<TABLE-PATH syntax="XPath">//Objects/SASLibrary</TABLE-PATH>';
75  put '<COLUMN name="LibraryId">><LENGTH>17</LENGTH>';
76  put '<PATH syntax="XPath">//Objects/SASLibrary/@Id</PATH></COLUMN>';
77  put '<COLUMN name="LibraryName"><LENGTH>256</LENGTH>>';
78  put '<PATH syntax="XPath">//Objects/SASLibrary/@Name</PATH></COLUMN>';
79  put '<COLUMN name="LibraryRef"><LENGTH>8</LENGTH>';
80  put '<PATH syntax="XPath">//Objects/SASLibrary/@Libref</PATH></COLUMN>';
81  put '<COLUMN name="Engine">><LENGTH>12</LENGTH>';
82  put '<PATH syntax="XPath">//Objects/SASLibrary/@Engine</PATH></COLUMN>';
83  put '</TABLE></SXLEMAP>';
84 run;
85 libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
86 
87 /* sort the response by library name */
88 proc sort data=_XML_.saslibrary out=&outds;
89  by libraryname;
90 run;
91 
92 
93 /* clear references */
94 filename sxlemap clear;
95 filename response clear;
96 libname _XML_ clear;
97 
98 %mend;