Get Physical Path From Metadata Libref

So it turns out that it is not possible to place a SAS lock on a table referenced via the Metadata Libname Engine:

WARNING: LOCK is not supported in MLE.

To circumvent this issue, one approach is to assign a libref directly. The following macro takes a libref (placed in the lib= keyword parameter) and queries the metadata for a physical path (placed in macro variable specified in the outvar= keyword parameter).

Note that not all librefs have an underlying directory (eg database tables).

%macro getpathfrommetalibref(lib=,outvar=filepath);
   data _null
      putlog “NOTE: Getting physical path for &lib library”;
      length liburi upuri filepath $256;
      call missing (of \
      /_ get URI for the particular library /
getnobj(“omsobj:[email protected] =’&lib’“,1,liburi);
      put rc1= lib
uri= ;
      /_ get first object of the UsingPackages association (assumed to be Path) /
      put rc2= upuri= ;
get the DirectoryName attribute of the previous object /
      put rc3= filepath=;
      call symputx(”&outvar”,filepath,‘g’);