To read directory from file reference

Reply
Occasional Contributor
Posts: 15

To read directory from file reference

Hi,

Is there is any way to read directory path from the file reference?

for e.g. I had file references declared in one stage of a program as: filename fref <dir>;

In other place I want to get the directory path <dir> only by using fref.

Please let me know how this can be done.

your help is much appreciated.

-Sudharsanan

Super User
Super User
Posts: 7,430

Re: To read directory from file reference

Hi,

You want:

data _null_;

  put %sysfunc(pathname( **your file refence** ));

run;

So the %sysfunc(pathname()) will return the address.

Super User
Super User
Posts: 6,502

Re: To read directory from file reference

You seem to have mixed macro and data step logic there.

In a data step you can call the PATHNAME() function directly.

data _null_;

  path = pathname('sashelp');

  put path=;

run;

In macro code you can call the PATHNAME() function using %SYSFUNC().

%put path=%sysfunc(pathname(sashelp));

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