BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

In my site we've multiple libraries and multiple datasets. If I want to find the library for some particular dataset, I manually looking at each of library to find if the dataset which I'm looking for is available. Is there any way to find the library of some particular dataset programmatically?

 

6 REPLIES 6
tomrvincent
Rhodochrosite | Level 12

Depends on the OS.  You're more likely to find it by searching withing Windows Explorer, grep (linux/unix) or something like those.  You certainly can use proc datasets to see all the datasets in a particular library, though.

utrocketeng
Quartz | Level 8

a long time ago, i find table sizes for each table in each predefined library.  i found a bit of starter code that i then modified.  this is what i am currently using:

 

proc sql;
create table VATableSize as
select libname, memname as TableName, nobs, filesize, obslen, nobs*obslen as Bytes, crdate, modate
from dictionary.tables
where NOT(libname IN ('MAPS','MAPSGFK','MAPSSAS','SAMPSIO','SASHELP', 'STPSAMP', 'WORK'))
ORDER BY FileSize Desc;
quit;

 

 

NOTE:  i run this in a program a few times a day, and dump the output to SAS Visual Analytics so that i can kinda keep tabs on various users data storage tendencies.

andreas_lds
Jade | Level 19

You can query sashelp.vtable:

 

proc sql;
   select LibName, MemName
      from sashelp.vtable
         where MemName = 'CLASS'
   ;
quit;

The name of the Dataset must be in upcase.

Kurt_Bremser
Super User

If you want to find the directory where dataset MYDATA is located, do this on UNIX:

find / -name mydata.sas7bdat

It's best to run this command as the superuser, because you'll get lots of messages about directories where you lack permissions otherwise.

Now, if you have a defined base directory for all your libraries, you can start there:

find /sasbase -name mydata.sas7bdat

And you'll only need a userid that has read/execute permissions on all the subdirectories there.

Kurt_Bremser
Super User

The problem with the dictionary.tables ( @utrocketeng) and sashelp.vtable ( @andreas_lds) approaches is that they only work on currently assigned libraries. They won't find any .sas7bdat files in directories where you do not have an active libname on.

tomrvincent
Rhodochrosite | Level 12

The OP did say 'libraries' and not 'directories', so I think the solutions offered will work.

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 5127 views
  • 4 likes
  • 5 in conversation