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