Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mm_getusers.sas
Go to the documentation of this file.
1 /**
2  @file mm_getusers.sas
3  @brief Creates a table containing a list of all users
4  @details Only shows a limited number of attributes as some sites will have a
5  LOT of users.
6 
7  Usage:
8 
9  %mm_getusers()
10 
11  @param outds the dataset to create that contains the list of libraries
12 
13  @returns outds dataset containing all users, with the following columns:
14  - uri
15  - name
16 
17  @warning The following filenames are created and then de-assigned:
18 
19  filename sxlemap clear;
20  filename response clear;
21  libname _XML_ clear;
22 
23  @version 9.3
24  @author Allan Bowe
25 
26 **/
27 
28 %macro mm_getusers(
29  outds=work.mm_getusers
30 )/*/STORE SOURCE*/;
31 
32 filename response temp;
33 proc metadata in= '<GetMetadataObjects>
34  <Reposid>$METAREPOSITORY</Reposid>
35  <Type>Person</Type>
36  <NS>SAS</NS>
37  <Flags>0</Flags>
38  <Options>
39  <Templates>
40  <Person Name=""/>
41  </Templates>
42  </Options>
43  </GetMetadataObjects>'
44  out=response;
45 run;
46 
47 filename sxlemap temp;
48 data _null_;
49  file sxlemap;
50  put '<SXLEMAP version="1.2" name="SASObjects"><TABLE name="SASObjects">';
51  put "<TABLE-PATH syntax='XPath'>/GetMetadataObjects/Objects/Person</TABLE-PATH>";
52  put '<COLUMN name="uri">';
53  put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/Person/@Id</PATH>";
54  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>32</LENGTH>";
55  put '</COLUMN><COLUMN name="name">';
56  put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/Person/@Name</PATH>";
57  put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>256</LENGTH>";
58  put '</COLUMN></TABLE></SXLEMAP>';
59 run;
60 libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
61 
62 proc sort data= _XML_.SASObjects out=&outds;
63  by name;
64 run;
65 
66 filename sxlemap clear;
67 filename response clear;
68 libname _XML_ clear;
69 
70 %mend;