How do i list all libraries and libref in SASApp

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How do i list all libraries and libref in SASApp

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
Solution
‎03-02-2018 12:57 PM
New Contributor
Posts: 3

Re: How do i list all libraries and libref in SASApp

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("omsobjSmiley FrustratedASLibrary?@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("omsobjSmiley FrustratedASLibrary?@Id contains '.'",nlibobj,liburi);

end;

run;

 

View solution in original post


All Replies
Super User
Posts: 5,876

Re: How do i list all libraries and libref in SASApp

What do you mean <exactly> with libraries?
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.
Data never sleeps
SAS Super FREQ
Posts: 9,366

Re: How do i list all libraries and libref in SASApp

Also, if you have a SASApp server and are using VA, there is a very good chance that your libraries are defined in the Metadata and controlled by the authorization settings in the Metadata.

So, you might have to use SAS Management Console to see the libraries that are defined.

cynthia
New Contributor
Posts: 3

Re: How do i list all libraries and libref in SASApp

Posted in reply to Cynthia_sas

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.

Solution
‎03-02-2018 12:57 PM
New Contributor
Posts: 3

Re: How do i list all libraries and libref in SASApp

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("omsobjSmiley FrustratedASLibrary?@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("omsobjSmiley FrustratedASLibrary?@Id contains '.'",nlibobj,liburi);

end;

run;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 141 views
  • 1 like
  • 3 in conversation