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