SAS Component Language Dictionary |
Returns the physical name of a SAS data library or an external
file
filename=PATHNAME(fileref);
|
-
filename
-
contains the physical name of an external
file or a SAS data library, or a blank if fileref
is invalid.
Type: Character
-
fileref
-
is the fileref assigned to an external file
or a SAS data library.
Type: Character
Use the FILEREF function to verify that the fileref MYFILE is associated with
an external file, and then use PATHNAME to retrieve the name of the external
file:
rc=fileref('myfile');
if (rc=0) then do;
fname=pathname('myfile');
put "Path = " fname;
end;
This example assigns
the fileref F1 to /u/sasssf
, and then uses F1 in a second call to FILENAME. The second call to
FILENAME defines the fileref F2 by appending /temp
to the path for F1.
rc=filename('f1','/u/sasssf');
path=pathname('f1');
put path=;
rc=filename('f2','temp',",",'f1');
path=pathname('f2');
put path=;
The output would be
path=/u/sasccf
path=/u/sasccf/temp
In this example,
FILENAME concatenates the directories /u/sasccf
and /u/sasshh
and assigns the concatenated list of names to the fileref F1. The
second call to FILENAME is the same as the second call to FILENAME in Example
2. However, in this example, because F1 is assigned to a concatenated list
of directory names instead of to a single directory, FILENAME does not append /temp
to the paths.
rc=filename('f1',"'/u/sasccf','/u/sasshh'");
path=pathname('f1');
put path=;
rc=filename('f2','temp',",",'f1');
path=pathname('f2');
put path=;
The output would be
path=('/u/sasccf','/u/sasshh')
path=('/u/sasccf','/u/sasshh')
FILENAME
FILEREF
FEXIST
FILEEXIST
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.