Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mm_getservercontexts.sas
Go to the documentation of this file.
1/**
2 @file mm_getservercontexts.sas
3 @brief Creates a dataset with all server contexts in all repos
4 @details
5 Usage:
6
7 %mm_getservercontexts(outds=mm_getservercontexts)
8
9 @param outds= the dataset to create that contains the list
10
11 @warning The following filenames are created and then de-assigned:
12
13 filename __mc1 clear;
14 filename __mc2 clear;
15 libname __mc3 clear;
16
17 <h4> SAS Macros </h4>
18 @li mm_getrepos.sas
19
20 @version 9.3
21 @author Allan Bowe
22
23**/
24
25%macro mm_getservercontexts(
26 outds=work.mm_getrepos
27)/*/STORE SOURCE*/;
28%local repo repocnt x;
29%let repo=%sysfunc(getoption(metarepository));
30
31/* first get list of available repos */
32%mm_getrepos(outds=work.repos)
33%let repocnt=0;
34data _null_;
35 set repos;
36 where repositorytype in('CUSTOM','FOUNDATION');
37 keep id name ;
38 call symputx('repo'!!left(_n_),name,'l');
39 call symputx('repocnt',_n_,'l');
40run;
41
42filename __mc1 temp;
43filename __mc2 temp;
44data &outds; length serveruri servername $200; stop;run;
45%do x=1 %to &repocnt;
46 options metarepository=&&repo&x;
47 proc metadata in=
48 "<GetMetadataObjects><Reposid>$METAREPOSITORY</Reposid>
49 <Type>ServerContext</Type><Objects/><NS>SAS</NS>
50 <Flags>0</Flags><Options/></GetMetadataObjects>"
51 out=__mc1;
52 run;
53 /*
54 data _null_;
55 infile __mc1 lrecl=1048576;
56 input;
57 put _infile_;
58 run;
59 */
60 data _null_;
61 file __mc2;
62 put '<SXLEMAP version="1.2" name="SASContexts"><TABLE name="SASContexts">';
63 put "<TABLE-PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext</TABLE-PATH>";
64 put '<COLUMN name="serveruri">';
65 put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext/@Id</PATH>";
66 put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
67 put '</COLUMN>';
68 put '<COLUMN name="servername">';
69 put "<PATH syntax='XPath'>/GetMetadataObjects/Objects/ServerContext/@Name</PATH>";
70 put "<TYPE>character</TYPE><DATATYPE>string</DATATYPE><LENGTH>200</LENGTH>";
71 put '</COLUMN>';
72 put '</TABLE></SXLEMAP>';
73 run;
74 libname __mc3 xml xmlfileref=__mc1 xmlmap=__mc2;
75 proc append base=&outds data=__mc3.SASContexts;run;
76 libname __mc3 clear;
77%end;
78
79options metarepository=&repo;
80
81filename __mc1 clear;
82filename __mc2 clear;
83
84%mend mm_getservercontexts;