Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
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 Optionally, filter for a user (useful to get the uri):
12
13 %mm_getusers(user=&_metaperson)
14
15 @returns outds dataset containing all users, with the following columns:
16 - uri
17 - name
18
19 @param [in] user= (0) Set to a metadata user to filter on that user
20 @param [out] outds= (work.mm_getusers) The output table to create
21
22 @version 9.3
23 @author Allan Bowe
24
25**/
26
27%macro mm_getusers(
28 outds=work.mm_getusers,
29 user=0
30)/*/STORE SOURCE*/;
31
32filename response temp;
33%if %superq(user)=0 %then %do;
34 proc metadata in= '<GetMetadataObjects>
35 <Reposid>$METAREPOSITORY</Reposid>
36 <Type>Person</Type>
37 <NS>SAS</NS>
38 <Flags>0</Flags>
39 <Options>
40 <Templates>
41 <Person Name=""/>
42 </Templates>
43 </Options>
44 </GetMetadataObjects>'
45 out=response;
46 run;
47%end;
48%else %do;
49 filename inref temp;
50 data _null_;
51 file inref;
52 put "<GetMetadataObjects>";
53 put "<Reposid>$METAREPOSITORY</Reposid>";
54 put "<Type>Person</Type>";
55 put "<NS>SAS</NS>";
56 put "<!-- Specify the OMI_XMLSELECT (128) flag -->";
57 put "<Flags>128</Flags>";
58 put "<Options>";
59 put "<Templates>";
60 put '<Person Name=""/>';
61 put "</Templates>";
62 length string $10000;
63 string=cats('<XMLSELECT search="Person[@Name=',"'&user'",']"/>');
64 put string;
65 put "</Options>";
66 put "</GetMetadataObjects>";
67 run;
68 proc metadata in=inref out=response;
69 run;
70%end;
71
72filename sxlemap temp;
73data _null_;
74 file sxlemap;
75 put '<SXLEMAP version="1.2" name="SASObjects"><TABLE name="SASObjects">';
76 put "<TABLE-PATH syntax='XPath'>/GetMetadataObjects/Objects/Person";
77 put "</TABLE-PATH>";
78 put '<COLUMN name="uri">';
79 put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/Person/@Id</PATH>";
80 put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>32</LENGTH>";
81 put '</COLUMN><COLUMN name="name">';
82 put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/Person/@Name</PATH>";
83 put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>256</LENGTH>";
84 put '</COLUMN></TABLE></SXLEMAP>';
85run;
86libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
87
88proc sort data= _XML_.SASObjects out=&outds;
89 by name;
90run;
91
92filename sxlemap clear;
93filename response clear;
94libname _XML_ clear;
95
96%mend mm_getusers;