Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mm_getobjects.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Creates a dataset with all metadata objects for a particular type
4
5 @param [in] type= the metadata type for which to return all objects
6 @param [out] outds= the dataset to create that contains the list of types
7
8 @returns outds dataset containing all objects
9
10 @warning The following filenames are created and then de-assigned:
11
12 filename sxlemap clear;
13 filename response clear;
14 libname _XML_ clear;
15
16 @version 9.2
17 @author Allan Bowe
18
19**/
20
21%macro mm_getobjects(
22 type=SASLibrary
23 ,outds=work.mm_getobjects
24)/*/STORE SOURCE*/;
25
26
27* use a temporary fileref to hold the response;
28filename response temp;
29/* get list of libraries */
30proc metadata in=
31 "<GetMetadataObjects><Reposid>$METAREPOSITORY</Reposid>
32 <Type>&type</Type><Objects/><NS>SAS</NS>
33 <Flags>0</Flags><Options/></GetMetadataObjects>"
34 out=response;
35run;
36
37/* write the response to the log for debugging */
38data _null_;
39 infile response lrecl=1048576;
40 input;
41 put _infile_;
42run;
43
44/* create an XML map to read the response */
45filename sxlemap temp;
46data _null_;
47 file sxlemap;
48 put '<SXLEMAP version="1.2" name="SASObjects"><TABLE name="SASObjects">';
49 put "<TABLE-PATH syntax='XPath'>/GetMetadataObjects/Objects/&type";
50 put "</TABLE-PATH>";
51 put '<COLUMN name="id">';
52 put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/&type/@Id</PATH>";
53 put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
54 put '</COLUMN><COLUMN name="name">';
55 put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/&type/@Name</PATH>";
56 put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
57 put '</COLUMN></TABLE></SXLEMAP>';
58run;
59libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
60
61proc sort data= _XML_.SASObjects out=&outds;
62 by name;
63run;
64
65/* clear references */
66filename sxlemap clear;
67filename response clear;
68libname _XML_ clear;
69
70%mend mm_getobjects;