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 \all);
/_ get URI for the particular library /
rc1=metadatagetnobj(“omsobj:SASLibrary?@Libref =’&lib’“,1,liburi);
put rc1= liburi= ;
/_ get first object of the UsingPackages association (assumed to be Path) /
rc2=metadatagetnasn(liburi,‘UsingPackages’,1,upuri);
put rc2= upuri= ;
/ get the DirectoryName attribute of the previous object /
rc3=metadatagetattr(up_uri,‘DirectoryName’,filepath);
put rc3= filepath=;
call symputx(”&outvar”,filepath,‘g’);
run;
%mend;