Production Ready Macros for SAS Application Developers
mm_gettypes.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Creates a dataset with all metadata types
4 
5  @param outds the dataset to create that contains the list of types
6 
7  @returns outds dataset containing all types
8 
9  @warning The following filenames are created and then de-assigned:
10 
11  filename sxlemap clear;
12  filename response clear;
13  libname _XML_ clear;
14 
15  @version 9.2
16  @author Allan Bowe
17 
18 **/
19 
20 %macro mm_gettypes(
21  outds=work.mm_gettypes
22 )/*/STORE SOURCE*/;
23 
24 * use a temporary fileref to hold the response;
25 filename response temp;
26 /* get list of libraries */
27 proc metadata in=
28  '<GetTypes>
29  <Types/>
30  <NS>SAS</NS>
31  <!-- specify the OMI_SUCCINCT flag -->
32  <Flags>2048</Flags>
33  <Options>
34  <!-- include <REPOSID> XML element and a repository identifier -->
35  <Reposid>$METAREPOSITORY</Reposid>
36  </Options>
37 </GetTypes>'
38  out=response;
39 run;
40 
41 /* write the response to the log for debugging */
42 data _null_;
43  infile response lrecl=1048576;
44  input;
45  put _infile_;
46 run;
47 
48 /* create an XML map to read the response */
49 filename sxlemap temp;
50 data _null_;
51  file sxlemap;
52  put '<SXLEMAP version="1.2" name="SASTypes"><TABLE name="SASTypes">';
53  put '<TABLE-PATH syntax="XPath">//GetTypes/Types/Type</TABLE-PATH>';
54  put '<COLUMN name="ID">';
55  put '<PATH syntax="XPath">//GetTypes/Types/Type/@Id</PATH></COLUMN>';
56  put '<COLUMN name="Desc">';
57  put '<PATH syntax="XPath">//GetTypes/Types/Type/@Desc</PATH></COLUMN>';
58  put '<COLUMN name="HasSubtypes">';
59  put '<PATH syntax="XPath">//GetTypes/Types/Type/@HasSubtypes</PATH></COLUMN>';
60  put '</TABLE></SXLEMAP>';
61 run;
62 libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
63 /* sort the response by library name */
64 proc sort data=_XML_.sastypes out=sastypes;
65  by id;
66 run;
67 
68 
69 /* clear references */
70 filename sxlemap clear;
71 filename response clear;
72 libname _XML_ clear;
73 
74 %mend;