Skip to content

Instantly share code, notes, and snippets.

@frayos
Created November 22, 2017 10:02
Show Gist options
  • Save frayos/d6eba85a4d7843490f0bbb420c4e65a7 to your computer and use it in GitHub Desktop.
Save frayos/d6eba85a4d7843490f0bbb420c4e65a7 to your computer and use it in GitHub Desktop.
SAS Metadata Properties Analysis to XML
/******************************************************************************************************************/
/* SOURCE : ftp://ftp.sas.com/techsup/download/web/60811GetSoftwareComponentsandServerComponents.sas */
/* Set the metadata options to match your environment. */
/* Save this program to the your home directory (cd ~ or cd !HOME). Name it GetSoftwareandServerComponents.sas */
/* On Unix systems run the code using a command like the following: */
/* <SASHome>/SASFoundation/9.4/sas ~/GetSoftwareandServerComponents.sas -log ~/GetSoftwareandServerComponents.log */
/* Replace <SASHome> with the actual location SAS is installed on your system. */
/* Retrieve and send the *TWO* XML files created named: GetSoftwareComponents.xml and GetServerComponents.xml */
/* By default they are placed in your home directory (~ or !HOME). */
/* 11/6/2015 - fix missing close on <GetMetadataObjects> and added sysdate to xml file name */
/* 11/24/2015 - improved GetMetadataObjects to extract more information, including modeled properties */
/* 3/27/2017 - improved extract for Server components to retrieve information more helpful for debugging BRT */
/* 6/29/2017 - added logic to extract port numbers on server objects */
/******************************************************************************************************************/
options metaserver='your.metadata.host'
metaport=8561
metaprotocol='bridge'
metauser='sasadm@saspw'
metapass='password'
metarepository='Foundation'
;
%let mshost=%sysfunc(getoption(METASERVER)) ;
%let response=out=response;
%macro setf ;
%if %index (&SYSSCP, WIN) %then %do ;
filename response "%USERPROFILE%\GetSoftwareComponents_&mshost._&sysdate9..xml";
filename server "%USERPROFILE%\GetServerComponents_&mshost._&sysdate9..xml";
%end;
%else %do;
filename response "$HOME/GetSoftwareComponents_&mshost._&sysdate9..xml";
filename server "$HOME/GetServerComponents_&mshost._&sysdate9..xml";
%end;
%mend ;
%setf ;
filename request temp;
data _null_;
file request;
input;
*_infile_ = resolve(_infile_);
put _infile_ ' ';
cards4;
<GetMetadataObjects>
<Reposid>$METAREPOSITORY</Reposid>
<Type>SoftwareComponent</Type>
<ns>SAS</ns>
<!-- Specify OMI_GET_METADATA(256) + OMI_INCLUDE_SUBTYPES (16) + OMI_TEMPLATE (4) + OMI_XMLSELECT (128) OMI_ALL (1)
+ OMI_SUCCINCT (2048) flags -->
<Flags>2453</Flags>
<Options>
<XMLSelect
search="@Id contains '.' "/>
<Templates>
<SoftwareComponent Id="" Name="" ClassIdentifier="" Major="" Minor="" MetadataCreated="" MetadataUpdated="">
</SoftwareComponent>
<Textstore Id="" Name="" MetadataCreated="" MetadataUpdated="" StoredText="" />
<PropertySet Id="" MetadataCreated="" MetadataUpdated="" Name="" PropertySetName="" />
<Document Id="" MetadataCreated="" MetadataUpdated="" Name="" URI="" URIType="" />
<Property Id="" DefaultValue="" Desc="" IsLinked="" IsRequired="" IsUpdateable="" IsVisible=""
MetadataCreated="" MetadataUpdated="" Name="" PropertyName="" PropertyRole="" SQLType="" UseValueOnly=""/>
<Tree Id="" Desc="" IsHidden="" MetadataCreated="" MetadataUpdated="" Name="" PublicType="" TreeType="" />
</Templates>
</Options>
</GetMetadataObjects>
;;;;
run;
proc metadata
in=request verbose &response;
run;
%let server=out=server;
filename request temp;
data _null_;
file request;
input;
*_infile_ = resolve(_infile_);
put _infile_ ' ';
cards4;
<GetMetadataObjects>
<Reposid>$METAREPOSITORY</Reposid>
<Type>ServerComponent</Type>
<Objects/>
<ns>SAS</ns>
<!-- Specify OMI_GET_METADATA(256) + OMI_ALL_SIMPLE (8) + OMI_INCLUDE_SUBTYPES (16) + OMI_TEMPLATE (4) +
OMI_ALL (1) + OMI_SUCCINCT (2048) flags -->
<Flags>2453</Flags>
<Options>
<XMLSelect
search="@Id contains '.' "/>
<Templates>
<ServerComponent Id="" Name="" ClassIdentifier="" Major="" Minor="" MetadataCreated="" MetadataUpdated="">
<SourceConnections>
<SASClientConnection>
<Domain>
<AuthenticationDomain />
</Domain>
<Properties>
<Property />
</Properties>
</SASClientConnection>
</SourceConnections>
</ServerComponent>
<SASClientConnection Id="" Name="" MetadataCreated="" MetadataUpdated="" Desc="">
<Domain>
<AuthenticationDomain />
</Domain>
<Properties>
<Property />
</Properties>
</SASClientConnection>
<AuthenticationDomain Id="" Name="" MetadataCreated="" MetadataUpdated="" Desc="" />
<Property Id="" DefaultValue="" Desc="" IsLinked="" IsRequired="" IsUpdateable="" IsVisible="" MetadataCreated=""
MetadataUpdated="" Name="" PropertyName="" PropertyRole="" SQLType="" UseValueOnly=""/>
<Machine Id="" Name="" MetadataCreated="" MetadataUpdated="" Desc="" />
<ResponsibleParty Id="" Name="" MetadataCreated="" MetadataUpdated="" Desc=""/>
<SoftwareComponent Id="" Name="" MetadataCreated="" MetadataUpdated="" Desc=""/>
<ServiceType Id="" Name="" MetadataCreated="" MetadataUpdated="" Desc=""/>
<TCPIPConnection Id="" Name="" HostName="" MetadataCreated="" MetadataUpdated="" Port="" Desc=""/>
<Textstore Id="" Name="" MetadataCreated="" MetadataUpdated="" StoredText="" />
</Templates>
</Options>
</GetMetadataObjects>
;;;;
run;
proc metadata
in=request verbose &server;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment