Issue:
How to find whether the library is pre-assigned or not?Solution:
I got the below code from SAS Tech support. It will show all library names, engine, path and pre-assigned details.
data
metadata_libraries;
length liburi
upasnuri $256 name $128 type id $17
libref engine $8 path mdschemaname schema $256
preassign $ 1 mdCreated mdUpdated $ 18;
keep name
libref engine path mdschemaname schema preassign mdCreated mdUpdated;
call
missing(liburi,upasnuri,name,engine,libref,preassign,mdCreated,mdUpdated);
/* Get each
Library object */
nlibobj=1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains
'.'",nlibobj,liburi);
/* For each
library, retrieve the libref, engine, path */
do while
(librc>0);
/* Get Library attributes */
rc=metadata_getattr(liburi,'Name',name);
rc=metadata_getattr(liburi,'Engine',engine);
rc=metadata_getattr(liburi,'Libref',libref);
rc=metadata_getattr(liburi,'IsPreassigned',preassign);
rc=metadata_getattr(liburi,'MetadataCreated',mdCreated);
rc=metadata_getattr(liburi,'MetadataUpdated',mdUpdated);
/*
Get the Directory and DatabaseSchema object
associated with this library via a
UsingPackages
association*/
n=1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
/* We found a UsingPackages association */
if uprc > 0 then do;
/* Determine object type */
call missing(type,id,path,mdschemaname,schema);
rc=metadata_resolve(upasnuri,type,id);
if type='Directory' then do;
/* Get the path and output the record */
rc=metadata_getattr(upasnuri,'DirectoryName',path);
output;
end; /*if type='Directory'*/
else if type='DatabaseSchema' then do;
/* Get the schema and output the record */
rc=metadata_getattr(upasnuri,'Name',mdschemaname);
rc=metadata_getattr(upasnuri,'SchemaName',schema);
output;
end; /*if type='DatabaseSchema'*/
/*Check to see if there are any more
Directory objects*/
n+1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
end; /*if uprc > 0*/
/*Look for another library*/
nlibobj+1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains
'.'",nlibobj,liburi);
end; /*do
while (librc>0)*/
run;
proc print
data=work.metadata_libraries;
var name
engine path preassign;
run;
Comments
Post a Comment