METADATA Procedure

Example 8: Request the Metadata for One Type of Object

Features:

IN= argument

Other features:

<Flags> element

<XMLSelect> element

This code submits a GetMetadataObjects method to list all objects of the specified type from the specified repository. The metadata server returns metadata for SAS Information Maps that are registered in the specified repository. A SAS Information Map is represented in a metadata repository with a primary object of the Transformation metadata type. Several other objects in the type dictionary use the Transformation metadata type as their primary metadata type. For example, SAS reports also use the Transformation metadata type. SAS supports two types of information maps: information maps for relational tables and information maps for cubes.
In this request, which specifies a flag value of 128, the GetMetadataObjects OMI_XMLSELECT flag filters the request to retrieve only Transformation objects describing information maps for relational tables. An information map for a relational table has a TypeName= value of "InformationMap.Relational” in its type definition.
The request is submitted from a temporary input file to simplify quoting requirements for the <XMLSELECT search="string"/> element. The results are written to an output XML file so that they can be easily viewed in a browser.
For details about information maps, see the Base SAS Guide to Information Maps. For information about type definitions and the type dictionary, see Using Language Elements That Read and Write Metadata. For information about PROC METADATA quoting requirements, see Quotation Requirements. This example shows a simple search string. For information about how to build a more complex search string, see SAS Open Metadata Interface: Reference and Usage.
Submit the GetMetadataObjects method.This request specifies to get information maps for relational tables.
filename myinput temp lrecl=256;
filename myoutput "C:\results2.xml" lrecl=256;

data _null_;
   file myinput;
   input;
   put _infile_ ' ';
   datalines;
<GetMetadataObjects>
 <Reposid>$METAREPOSITORY</Reposid>
 <Type>Transformation</Type>
 <Objects/>
 <NS>SAS</NS>
 <Flags>2440</Flags>
 <Options>
  <XMLSelect search="*[@PublicType='InformationMap.Relational']"/>
 </Options>
</GetMetadataObjects>
;;
run;

proc metadata
   in=myinput
   out=myoutput;
run;
Here is an example of the output. This request returns one object, shown in the <OBJECTS> XML element. To get the information, such as the responsible parties for the information map and the tables on which the information map is defined, you can set the OMI_GET_METADATA (256), OMI_ALL (8), and OMI_SUCCINCT (2048) flags in the request. To set the flags, add their values to OMI_XMLSELECT (128), and specify the total in the <FLAGS> XML element. The OMI_GET_METADATA flag enables you to set GetMetadata flags in the GetMetadataObjects request. These flags can return a lot of information, so they should be set only when a few objects are expected to be returned by GetMetadataObjects.
The following is the content of the output file, opened in a browser.
Contents of the results2.xml File
Contents of the results2.xml file, opened in a browser