Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mm_getrepos.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Creates a dataset with all available repositories
4 
5  @param outds= the dataset to create that contains the list of repos
6 
7  @returns outds dataset containing all repositories
8 
9  @warning The following filenames are created and then de-assigned:
10 
11  filename sxlemap clear;
12  filename response clear;
13  libname _XML_ clear;
14 
15  @version 9.2
16  @author Allan Bowe
17 
18 **/
19 
20 %macro mm_getrepos(
21  outds=work.mm_getrepos
22 )/*/STORE SOURCE*/;
23 
24 
25 * use a temporary fileref to hold the response;
26 filename response temp;
27 /* get list of libraries */
28 proc metadata in=
29  "<GetRepositories><Repositories/><Flags>1</Flags><Options/></GetRepositories>"
30  out=response;
31 run;
32 
33 /* write the response to the log for debugging */
34 /*
35 data _null_;
36  infile response lrecl=1048576;
37  input;
38  put _infile_;
39 run;
40 */
41 
42 /* create an XML map to read the response */
43 filename sxlemap temp;
44 data _null_;
45  file sxlemap;
46  put '<SXLEMAP version="1.2" name="SASRepos"><TABLE name="SASRepos">';
47  put "<TABLE-PATH syntax='XPath'>/GetRepositories/Repositories/Repository</TABLE-PATH>";
48  put '<COLUMN name="id">';
49  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Id</PATH>";
50  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
51  put '</COLUMN>';
52  put '<COLUMN name="name">';
53  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Name</PATH>";
54  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
55  put '</COLUMN>';
56  put '<COLUMN name="desc">';
57  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Desc</PATH>";
58  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
59  put '</COLUMN>';
60  put '<COLUMN name="DefaultNS">';
61  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@DefaultNS</PATH>";
62  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
63  put '</COLUMN>';
64  put '<COLUMN name="RepositoryType">';
65  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@RepositoryType</PATH>";
66  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>20</LENGTH>";
67  put '</COLUMN>';
68  put '<COLUMN name="RepositoryFormat">';
69  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@RepositoryFormat</PATH>";
70  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>10</LENGTH>";
71  put '</COLUMN>';
72  put '<COLUMN name="Access">';
73  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Access</PATH>";
74  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>16</LENGTH>";
75  put '</COLUMN>';
76  put '<COLUMN name="CurrentAccess">';
77  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@CurrentAccess</PATH>";
78  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>16</LENGTH>";
79  put '</COLUMN>';
80  put '<COLUMN name="PauseState">';
81  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@PauseState</PATH>";
82  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>16</LENGTH>";
83  put '</COLUMN>';
84  put '<COLUMN name="Path">';
85  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Path</PATH>";
86  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>256</LENGTH>";
87  put '</COLUMN>';
88  put '<COLUMN name="Engine">';
89  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Engine</PATH>";
90  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>8</LENGTH>";
91  put '</COLUMN>';
92  put '<COLUMN name="Options">';
93  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Options</PATH>";
94  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>32</LENGTH>";
95  put '</COLUMN>';
96  put '<COLUMN name="MetadataCreated">';
97  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@MetadataCreated</PATH>";
98  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>24</LENGTH>";
99  put '</COLUMN>';
100  put '<COLUMN name="MetadataUpdated">';
101  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@MetadataUpdated</PATH>";
102  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>24</LENGTH>";
103  put '</COLUMN>';
104  put '</TABLE></SXLEMAP>';
105 run;
106 libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
107 
108 proc sort data= _XML_.SASRepos out=&outds;
109  by name;
110 run;
111 
112 /* clear references */
113 filename sxlemap clear;
114 filename response clear;
115 libname _XML_ clear;
116 
117 %mend;