01-17-2018 07:56 AM
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?
01-17-2018 08:17 AM
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.
01-17-2018 08:24 AM
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:
create table VATableSize as
select libname, memname as TableName, nobs, filesize, obslen, nobs*obslen as Bytes, crdate, modate
where NOT(libname IN ('MAPS','MAPSGFK','MAPSSAS','SAMPSIO','SASHELP', 'STPSAMP', 'WORK'))
ORDER BY FileSize Desc;
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.
01-17-2018 08:31 AM
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.
01-17-2018 08:33 AM
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.
01-17-2018 08:37 AM
The problem with the dictionary.tables ( @utrocketengineer) 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.