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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.