03-27-2014 06:08 AM
I need to automatically check properties (paths, engine, access (readonly or not)) of all libraries in a session. In SAS 9.2 these are conveniently stored in sashelp.vlibnam. In SAS 8.2 I only found the libname function (which gives only the path), and that the properties can be displayed in the log window with statement libname <libref> list; Is there any possibility to get the output of this statement into a variable or macro variable? Or is there any other way to get this information?
03-27-2014 07:28 AM
Well, a couple of workarounds perhaps:
- Get the pathname of a library.
- Check access to a library
libname rob "S:\Temp\Rob" access=read;
attrib a format=1.;
- File will not exist as write protected (make sure to delete your temp ds if it is created.
- Still thinking about engine (haven't got 8.2 so can't try things).
03-27-2014 12:00 PM
You can use the dictionary tables with proc sql and into: to put them in macro vars.
03-28-2014 06:17 AM
Thanks for your replies. Unfortunately, the dictionary tables in SAS 8.2 do not contain suitable libname information except the pathname.
I found another solution:
ods listing close;
ods output Contents.Directory(match_all=DIRECTORIES) = <libname>;
proc contents data = <libname>._all_ nods;
The resulting dataset work.<libname> contains the information that you would get in the log file with libname <libname> list;
In case there is more than one level, detailed information is put into <libname>1, <libname>2, etc., while <libname> only contains information about the number of levels.