The SAS 9.2 XML engine is very very very slick. I created an xml map to generate a dataset from xml generated during a metadata getobjects job to then run call execute statements for a proc metalib update. "Wait, you did what??!@#?&" you ask?
Here are my simple steps. This then can run in the background to update all the SAS Metadata to match the physical tables.
1. Generate XML results from a Metadata GetMetadataObjects Job
data _null_;
file request;
put '<GetMetadataObjects>';
put '<Reposid>$METAREPOSITORY</Reposid>';
put ' <Type>SASLibrary</Type>';
put ' <Objects/>';
put ' <NS>SAS</NS>';
put ' <Flags>0</Flags>';
put '</GetMetadataObjects>';
run;
2. Submit the Request to the Metadata Server
proc metadata in=request out=resultsfile; run;
3. Create an XMLMap file to read in the Metadata.
<?xml version="1.0" ?>
<SXLEMAP version="1.2">
<TABLE name="librefs">
<TABLE-PATH syntax="XPATH">/GetMetadataObjects/Objects/SASLibrary</TABLE-PATH>
<COLUMN name="library" retain="YES">
<PATH>/GetMetadataObjects/Objects/SASLibrary@Name</PATH>
<TYPE>character</TYPE>
<DATATYPE>STRING</DATATYPE>
<LENGTH>30</LENGTH>
</COLUMN>
</TABLE>
</SXLEMAP>
4. Utilize an XML map to then read these results into a SAS dataset.
libname out xml resultsfilepath xmlmap=mapfilepath;
5. Run call execute statements to update the metadata for each existing library.
data _null_;
set out.librefs;
call execute("proc metalib;");
call execute("omr (library='"library"' repname='Foundation');");
call execute("update_rule=(delete);");
call execute("run;");
run;