Hi there,
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?
Thanks,
Anja
Well, a couple of workarounds perhaps:
- Get the pathname of a library.
%put %sysfunc(pathname(work));
- Check access to a library
libname rob "S:\Temp\Rob" access=read;
data rob.test;
attrib a format=1.;
a=1;
output;
run;
%put %sysfunc(fileexist(rob.test));
- 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).
You can use the dictionary tables with proc sql and into: to put them in macro vars.
.
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;
run;
ods listing;
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.