The data comes from a system query of the metadata server (PROC METADATA) and is processed via temporary files generated by the script.
1 Code Block
PROC METADATA
Explanation : Sends a formatted XML request to the metadata server to retrieve the list of available object types. The response is stored in the temporary fileref 'response'.
Copied!
filename response temp;
/* get list of libraries */
proc metadata in=
'<GetTypes>
<Types/>
<NS>SAS</NS>
<!-- specify the OMI_SUCCINCT flag -->
<Flags>2048</Flags>
<Options>
<!-- include <REPOSID> XML element and a repository identifier -->
<Reposid>$METAREPOSITORY</Reposid>
</Options>
</GetTypes>'
out=response;
run;
1
filename response temp;
2
/* get list of libraries */
3
PROC METADATA in=
4
'<GetTypes>
5
<Types/>
6
<NS>SAS</NS>
7
<!-- specify the OMI_SUCCINCT flag -->
8
<Flags>2048</Flags>
9
<Options>
10
<!-- include <REPOSID> XML element and a repository identifier -->
11
<Reposid>$METAREPOSITORY</Reposid>
12
</Options>
13
</GetTypes>'
14
out=response;
15
RUN;
2 Code Block
DATA STEP
Explanation : Writes the raw XML response content to the SAS log for debugging purposes.
Copied!
data _null_;
infile response lrecl=1048576;
input;
put _infile_;
run;
1
DATA _null_;
2
INFILE response lrecl=1048576;
3
INPUT;
4
put _infile_;
5
RUN;
3 Code Block
DATA STEP
Explanation : Dynamically creates an 'XML Map' file (sxlemap) that defines how to parse the XML stream returned by PROC METADATA to extract a tabular structure.
Copied!
filename sxlemap temp;
data _null_;
file sxlemap;
put '<SXLEMAP version="1.2" name="SASTypes"><TABLE name="SASTypes">';
put '<TABLE-PATH syntax="XPath">//GetTypes/Types/Type</TABLE-PATH>';
put '<COLUMN name="ID"><LENGTH>64</LENGTH>';
put '<PATH syntax="XPath">//GetTypes/Types/Type/ @Id</PATH></COLUMN>';
/* ... (autres colonnes) ... */
put '</TABLE></SXLEMAP>';
run;
1
filename sxlemap temp;
2
DATA _null_;
3
file sxlemap;
4
put '<SXLEMAP version="1.2" name="SASTypes"><TABLE name="SASTypes">';
5
put '<TABLE-PATH syntax="XPath">//GetTypes/Types/Type</TABLE-PATH>';
6
put '<COLUMN name="ID"><LENGTH>64</LENGTH>';
7
put '<PATH syntax="XPath">//GetTypes/Types/Type/ @Id</PATH></COLUMN>';
8
/* ... (autres colonnes) ... */
9
put '</TABLE></SXLEMAP>';
10
RUN;
4 Code Block
PROC SORT Data
Explanation : Uses the LIBNAME XML engine to read the 'response' file by applying the 'sxlemap' map, then sorts the extracted data by the 'ID' column to create the final output table.
Copied!
libname _XML_ xml xmlfileref=response xmlmap=sxlemap;
/* sort the response by library name */
proc sort data=_XML_.sastypes out=&outds;
by id;
run;
1
LIBNAME _XML_ xml xmlfileref=response xmlmap=sxlemap;
2
/* sort the response by library name */
3
PROC SORTDATA=_XML_.sastypes out=&outds;
4
BY id;
5
RUN;
5 Code Block
Cleanup
Explanation : Releases references to temporary files and the XML library.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« This program is inseparable from the Open Metadata Architecture (OMA). In SAS Viya, this "Type" concept is replaced by resource definitions managed by various microservices (Folders, Files, Identities). Consequently, this code cannot be used to explore native Viya infrastructure unless you are working in a hybrid environment where Viya must still interact with a remote legacy 9.4 Metadata Server. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.