We have a mixed environment. We use Enterprise Guide connected to a SASApp ( 9.04.01M4P110916) server (windows X64_SR12R2) to prep our data. Then we us SAS Visual Analytics for reporting and analysis and SAS Studio for the odd coding tweaking.
We need to have an easy way to get a list of libraries and their librefs. I tried proc contents _all_ it does not list all the libraries, just SAS libraries. This is the code I have tried
proc sql noprint;
create table one as
select * from dictionary.libnames;
quit;
proc print;
run;
Again it only lists the SAS libraries but no user libraries. Any ideas how to get a full list of libraries in SASApp and their librefs?
Thanks
Darlene
I got some assistance from SAS Technical help and here is the code that worked for me.
data metadata_libraries;
length liburi upasnuri $256 name $128 type id $17 libref engine $8 path mdschemaname schema $256;
keep name libref engine path mdschemaname schema;
call missing(liburi,upasnuri,name,engine,libref);
nlibobj=1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
do while (librc>0);
rc=metadata_getattr(liburi,'Name',name);
rc=metadata_getattr(liburi,'Engine',engine);
rc=metadata_getattr(liburi,'Libref',libref);
n=1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
if uprc > 0 then do;
call missing(type,id,path,mdschemaname,schema);
rc=metadata_resolve(upasnuri,type,id);
if type='Directory' then do;
rc=metadata_getattr(upasnuri,'DirectoryName',path);
output;
end;
else if type='DatabaseSchema' then do;
rc=metadata_getattr(upasnuri,'Name',mdschemaname);
rc=metadata_getattr(upasnuri,'SchemaName',schema);
output;
end;
n+1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
end;
nlibobj+1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
end;
run;
Thanks for the reply. We already use SAS Management Console to manage libraries. The reason we need code to get a list of libraries is we are trying to write a report to automatically update the list of librefs that we need. it's easy to get the librefs in Enterprise Guide but not so straightforward in SAS Studio. So that's why we need to have a code snippet that will provide it.
I got some assistance from SAS Technical help and here is the code that worked for me.
data metadata_libraries;
length liburi upasnuri $256 name $128 type id $17 libref engine $8 path mdschemaname schema $256;
keep name libref engine path mdschemaname schema;
call missing(liburi,upasnuri,name,engine,libref);
nlibobj=1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
do while (librc>0);
rc=metadata_getattr(liburi,'Name',name);
rc=metadata_getattr(liburi,'Engine',engine);
rc=metadata_getattr(liburi,'Libref',libref);
n=1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
if uprc > 0 then do;
call missing(type,id,path,mdschemaname,schema);
rc=metadata_resolve(upasnuri,type,id);
if type='Directory' then do;
rc=metadata_getattr(upasnuri,'DirectoryName',path);
output;
end;
else if type='DatabaseSchema' then do;
rc=metadata_getattr(upasnuri,'Name',mdschemaname);
rc=metadata_getattr(upasnuri,'SchemaName',schema);
output;
end;
n+1;
uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri);
end;
nlibobj+1;
librc=metadata_getnobj("omsobj:SASLibrary?@Id contains '.'",nlibobj,liburi);
end;
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.