0

I've used this code to fetch the list of objects for all SAS Libraries, Physical Tables and Jobs. https://github.com/sasjs/core/blob/master/meta/mm_getobjects.sas I now need to fetch these objects details, Like for Libraries - I need their libname and full path, Teradata Libs - Schema Name,Lib path Physical Tables - Location and other attribs Jobs - Location, and other attribs.

I'm not very familiar on how or what attribs can we report, but I definitely need their paths and attribs. Thank you.

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
Rhea
  • 283
  • 1
  • 5
  • 17
  • Do you need the information from the Metadata server definitions? Or the information for the active librefs in the current SAS session? – Tom May 12 '19 at 05:06
  • I need it from the metadata repository. – Rhea May 12 '19 at 05:57

2 Answers2

1

The example you refer to is using proc metadata that returns XML you need to understand and process. The real problem here is you have to learn how to build input XML to construct the metadata query, which is quite a complex thing.

Maybe more straight forward is to use Data step metadata functions like here.

METABROWSE command is useful to understand metadata object relations (if you have access to SAS Foundation), see here

vasja
  • 4,732
  • 13
  • 15
  • Thanks Vasja, this Data step method worked and was very quick as well, do you know of any what options can we use to achieve the same thing for physical tables and Jobs? – Rhea May 12 '19 at 23:48
0

The attributes you are asking for will change depending on the library engine you are checking for.

The following macro will generate a libname for BASE, OLEDB, ODBC and POSTGRES engines (note that the repository has moved):

https://github.com/sasjs/core/blob/main/meta/mm_assigndirectlib.sas

The direct attributes are available as per this answer: How to get details of metadata objects in SAS

Folder path is available as per this answer:

%let metauri=OMSOBJ:PhysicalTable\A5HOSDWY.BE0006N9;
/* get metadata paths */
data ;
  length tree_path $500 tree_uri parent_uri parent_name $200;
  call missing(tree_path,tree_uri,parent_uri,parent_name);
  drop tree_uri parent_uri parent_name rc ;

  uri="&metauri";
  rc=metadata_getnasn(uri,"Trees",1,tree_uri);
  rc=metadata_getattr(tree_uri,"Name",tree_path);

  do while (metadata_getnasn(tree_uri,"ParentTree",1,parent_uri)>0);
    rc=metadata_getattr(parent_uri,"Name",parent_name);
    tree_path=strip(parent_name)||'/'||strip(tree_path);
    tree_uri=parent_uri;
  end;
  tree_path='/'||strip(tree_path);
run;
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124