- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Physically, and directory that holds a SAS file can be considered a library...
SAS code finds libraries that are assigned in the current session.
Another angle is to consider libraries that are registered in metadata.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So, you might have to use SAS Management Console to see the libraries that are defined.
cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;