BookmarkSubscribeRSS Feed
AnjaF
Calcite | Level 5

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

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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).

Patrick_Tan
Fluorite | Level 6

You can use the dictionary tables with proc sql and into:  to put them in macro vars.

.

http://www2.sas.com/proceedings/sugi30/070-30.pdf

AnjaF
Calcite | Level 5

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.

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1699 views
  • 0 likes
  • 3 in conversation