DATA Step, Macro, Functions and more

SAS 8.2: How to put library properties into (macro) variable(s)

Reply
New Contributor
Posts: 2

SAS 8.2: How to put library properties into (macro) variable(s)

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

Super User
Super User
Posts: 7,988

Re: SAS 8.2: How to put library properties into (macro) variable(s)

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

Occasional Contributor
Posts: 6

Re: SAS 8.2: How to put library properties into (macro) variable(s)

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

New Contributor
Posts: 2

Re: SAS 8.2: How to put library properties into (macro) variable(s)

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.

Ask a Question
Discussion stats
  • 3 replies
  • 475 views
  • 0 likes
  • 3 in conversation