/**
@file
@brief Creates a dataset with all metadata libraries
@details Will only show the libraries to which a user has the requisite
metadata access.
@param outds the dataset to create that contains the list of libraries
@param mDebug set to anything but * or 0 to show debug messages in the log
@returns outds dataset containing all groups in a column named "metagroup"
(defaults to work.mm_getlibs). The following columns are provided:
- LibraryId
- LibraryName
- LibraryRef
- Engine
@warning The following filenames are created and then de-assigned:
filename sxlemap clear;
filename response clear;
libname _XML_ clear;
@version 9.2
@author Allan Bowe
**/
%macro mm_getlibs(
outds=work.mm_getLibs
)/*/STORE SOURCE*/;
/*
flags:
OMI_SUCCINCT (2048) Do not return attributes with null values.
OMI_GET_METADATA (256) Executes a GetMetadata call for each object that
is returned by the GetMetadataObjects method.
OMI_ALL_SIMPLE (8) Gets all of the attributes of the requested object.
*/
data _null_;
flags=2048+256+8;
call symputx('flags',flags,'l');
run;
* use a temporary fileref to hold the response;
filename response temp;
/* get list of libraries */
proc metadata in=
'
$METAREPOSITORY
SASLibrary
SAS
&flags
'
out=response;
run;
/* write the response to the log for debugging */
data _null_;
infile response lrecl=32767;
input;
put _infile_;
run;
/* create an XML map to read the response */
filename sxlemap temp;
data _null_;
file sxlemap;
put '';
put '';
put '//Objects/SASLibrary';
put '>17';
put '//Objects/SASLibrary/@Id';
put '256>';
put '//Objects/SASLibrary/@Name';
put '8';
put '//Objects/SASLibrary/@Libref';
put '>12';
put '//Objects/SASLibrary/@Engine';
put '
';
run;
libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
/* sort the response by library name */
proc sort data=_XML_.saslibrary out=&outds;
by libraryname;
run;
/* clear references */
filename sxlemap clear;
filename response clear;
libname _XML_ clear;
%mend mm_getlibs;