Exploring SAS Metadata
SAS Display Manager has facilities that enable you to investigate SAS metadata. In the command box top left, enter the command “metabrowse”. A window pops up in which you need to enter your credentials for metadata access. The metadata browser then opens, looking something like this:
Here “Foundation” is the main repository, and “Bob” is a project repository belonging to a particular user. Choosing “Foundation” and expanding:
All the metadata types are now listed down the left-hand side, and it is possible to choose one of these, expand and explore. A good one to start with is DataTable. Expanding that node, and selecting the first table:
Table AUG_ASS has been selected, and details for it are now shown in the panel on the right-hand side. These details are all either attributes of the object itself, such as TableName, or associations i.e. links to objects of other types. A couple of particularly useful associations here are “Columns” and “TablePackage”. The “TablePackage” association, it turns out, links a DataTable object to the relevant SASLibrary object. These can be seen by expanding a few things on the left-hand side:
This table has two columns, called “culprit” and “opponent”, and belongs to a library called “SQLDATA”. We can expand the node for the “culprit” column a couple of times:
The column object has an association called “Table” that links back to the DataTable object called AUG_ASS. Notice that that object now appears in the tree twice. This really is exactly the same object both times, so presenting the metadata in a tree structure is actually a little misleading. SAS metadata is not structured as a tree, but as a complex of interlinked objects. It is easy to confuse yourself, thinking you are going deeper in, when in fact you are going around in circles.
One particular association that’s worth knowing about is “Trees”. By following this, and subsequent “ParentTree” associations, you can locate an object within the metadata hierarchy (as viewed in SAS Management Console or DI Studio).
A different problem is locating a metadata object from its metadata ID. For example, when a DI Studio job is run, for each step there is a line in the log like:
%let transformID = %quote(A5JHQ96U.AL00000Q);
The quoted string here is a metadata ID, but how to locate the corresponding object, when we don’t know what type it is? Happily there is a companion program to metabrowse, called “metafind”. On entering “metafind” into the Display Manager command box, you will be prompted for metadata credentials as before, and then to select a repository and enter a metadata ID (or URI – “Universal Resource Identifier”):
Clicking the “Find” button reveals:
So that line in the log file is referring to a TransformationStep object.
The details of how metadata objects are linked together are often complex, but you now have all the information you should need to start exploring. If you then want to write a program to extract information from metadata, there are subroutines METADATA_GETATTR and METADATA_GETNASN which enable this to be done.
NB All of the above refers to read-only access to metadata. Any attempt at writing to SAS metadata cannot be discouraged too strongly.
The “metabrowse” and “metafind” commands are specific to Display Manager.