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