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 [out] outds= (work.mm_getrepos)
6  The dataset to create that contains the list of repos
7 
8  @returns outds dataset containing all repositories
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_getrepos(
22  outds=work.mm_getrepos
23 )/*/STORE SOURCE*/;
24 
25 
26 * use a temporary fileref to hold the response;
27 filename response temp;
28 /* get list of libraries */
29 proc metadata in=
30  "<GetRepositories><Repositories/><Flags>1</Flags><Options/></GetRepositories>"
31  out=response;
32 run;
33 
34 /* write the response to the log for debugging */
35 /*
36 data _null_;
37  infile response lrecl=1048576;
38  input;
39  put _infile_;
40 run;
41 */
42 
43 /* create an XML map to read the response */
44 filename sxlemap temp;
45 data _null_;
46  file sxlemap;
47  put '<SXLEMAP version="1.2" name="SASRepos"><TABLE name="SASRepos">';
48  put "<TABLE-PATH syntax='XPath'>/GetRepositories/Repositories/Repository";
49  put "</TABLE-PATH>";
50  put '<COLUMN name="id">';
51  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Id";
52  put "</PATH>";
53  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
54  put '</COLUMN>';
55  put '<COLUMN name="name">';
56  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Name";
57  put "</PATH>";
58  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
59  put '</COLUMN>';
60  put '<COLUMN name="desc">';
61  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Desc";
62  put "</PATH>";
63  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
64  put '</COLUMN>';
65  put '<COLUMN name="DefaultNS">';
66  put "<PATH syntax='XPath'>";
67  put "/GetRepositories/Repositories/Repository/@DefaultNS</PATH>";
68  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
69  put '</COLUMN>';
70  put '<COLUMN name="RepositoryType">';
71  put "<PATH syntax='XPath'>";
72  put "/GetRepositories/Repositories/Repository/@RepositoryType</PATH>";
73  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>20</LENGTH>";
74  put '</COLUMN>';
75  put '<COLUMN name="RepositoryFormat">';
76  put "<PATH syntax='XPath'>";
77  put "/GetRepositories/Repositories/Repository/@RepositoryFormat</PATH>";
78  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>10</LENGTH>";
79  put '</COLUMN>';
80  put '<COLUMN name="Access">';
81  put "<PATH syntax='XPath'>";
82  put "/GetRepositories/Repositories/Repository/@Access</PATH>";
83  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>16</LENGTH>";
84  put '</COLUMN>';
85  put '<COLUMN name="CurrentAccess">';
86  put "<PATH syntax='XPath'>";
87  put "/GetRepositories/Repositories/Repository/@CurrentAccess</PATH>";
88  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>16</LENGTH>";
89  put '</COLUMN>';
90  put '<COLUMN name="PauseState">';
91  put "<PATH syntax='XPath'>";
92  put "/GetRepositories/Repositories/Repository/@PauseState</PATH>";
93  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>16</LENGTH>";
94  put '</COLUMN>';
95  put '<COLUMN name="Path">';
96  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Path";
97  put "</PATH>";
98  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>256</LENGTH>";
99  put '</COLUMN>';
100  put '<COLUMN name="Engine">';
101  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Engine";
102  put "</PATH>";
103  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>8</LENGTH>";
104  put '</COLUMN>';
105  put '<COLUMN name="Options">';
106  put "<PATH syntax='XPath'>/GetRepositories/Repositories/Repository/@Options";
107  put "</PATH>";
108  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>32</LENGTH>";
109  put '</COLUMN>';
110  put '<COLUMN name="MetadataCreated">';
111  put "<PATH syntax='XPath'>";
112  put "/GetRepositories/Repositories/Repository/@MetadataCreated</PATH>";
113  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>24</LENGTH>";
114  put '</COLUMN>';
115  put '<COLUMN name="MetadataUpdated">';
116  put "<PATH syntax='XPath'>";
117  put "/GetRepositories/Repositories/Repository/@MetadataUpdated</PATH>";
118  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>24</LENGTH>";
119  put '</COLUMN>';
120  put '</TABLE></SXLEMAP>';
121 run;
122 libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
123 
124 proc sort data= _XML_.SASRepos out=&outds;
125  by name;
126 run;
127 
128 /* clear references */
129 filename sxlemap clear;
130 filename response clear;
131 libname _XML_ clear;
132 
133 %mend mm_getrepos;