Previous Page | Next Page

Examples: Using Metadata Language Elements

Example: Creating a PropertySet Object for Use with LIBOPTSET=

The metadata LIBNAME statement supports the LIBOPTSET= argument, which specifies a PropertySet object. The PropertySet object is associated to Property objects that store information. This information is used to construct a LIBNAME statement for the underlying engine.

In this release of SAS, no products enable you to directly create a PropertySet object. Instead, you can use code like this example to programmatically create the object.

The example uses the DATA step with PUT statements to create a temporary XML file. Then the METADATA procedure submits the XML file to the metadata server in order to add the metadata objects.

The PropertySet object has an OwningObject of SASLibrary, and the Property objects need an OwningType and PropertyType. This example defines a PropertyType with Name="String" and SQLType="1".

options metaserver="my-metadata-server"
    metaport=8561
    metauser="my-id"
    metapass="my-pw"
    metarepository="Foundation";

/*provide the name of the metadata library with which to associate this set of options*/
%let LibraryName=Oracle Library;

/*provide a name for the PropertySet object*/
%let PropSetName=SetOraBuffOptions;

/*create temporary files for building and receiving XML for PROC METADATA*/
filename inxml temp lrecl=32767;
filename outxml temp lrecl=32767;

/*generate the temporary IN= XML file for PROC METADATA*/
data _null_;
   length uri $256 LibId $17;

   /*retrieve the uri for the requested library*/
    rc=metadata_getnobj("omsobj:SASLibrary?@Name='"||"&LibraryName"||"'", 1, uri);
  
   /*verify that the library exists in the metadata, if so retrieve the metadata Id*/
   if rc <= 0 then put 'Library not found in metadata';
   else rc=metadata_getattr(uri,'Id',LibId);
      
   /*build the XML for PROC METADATA to add the new PropertySet to the metadata*/
   file inxml;
   put '<AddMetadata>';
   put ' <Metadata>';
          /*the <PropertySet> tag creates the object with the name from %LET above*/
   put '  <PropertySet Name="'"&PropSetName"'"';
   put '   Desc="Set ReadBuff=50 and InsertBuff=100">';
           /*the PropertySet will be owned by the library specified in the %LET above*/
   put '   <OwningObject>';
   put '    <SASLibrary ObjRef="'LibId'" />';
   put '   </OwningObject>';
           /*each object is defined as a <Property>*/
   put '   <SetProperties>';
   put '    <Property Name="Block insert buffer size" DefaultValue="50" Delimiter="=" ';
   put '     PropertyName="INSERTBUFF" UseValueOnly="0">';
   put '    </Property>';
   put '    <Property Name="Block read buffer size" DefaultValue="100" Delimiter="=" ';
   put '     PropertyName="READBUFF" UseValueOnly="0">';
   put '    </Property>';
   put '    <Property Name="Use extended memory" DefaultValue="MEMLIB" UseValueOnly="1">';
   put '    </Property>';
   put '   </SetProperties>';
   put '  </PropertySet>';
   put ' </Metadata>';
   put ' <Reposid>$METAREPOSITORY</Reposid>';
   put ' <NS>SAS</NS>';
   put ' <Flags>268435456</Flags>';
   put ' <Options/>';
   put '</AddMetadata>';
run;

/*pass the XML to PROC METADATA to create the new PropertySet in the metadata*/
proc metadata in=inxml out=outxml header=full verbose;
run;

After an administrator submits the previous code to set the LIBNAME options, a user can submit the following code to assign the library:

libname mylib meta library="Oracle Library" liboptset="SetOraBuffOptions";

The options INSERTBUFF=50, READBUFF=100, and MEMLIB are applied to the library. For more information, see How the Metadata Engine Constructs Options.

Previous Page | Next Page | Top of Page