PATHNAME Function

Returns the physical name of an external file or a SAS library, or returns a blank.

Categories: SAS File I/O
External Files
See: PATHNAME Function: UNIX in SAS Companion for UNIX Environments
PATHNAME Function: z/OS in SAS Companion for z/OS

Syntax

PATHNAME((fileref | libref) <,search-ref> )

Required Arguments

fileref

is a character constant, variable, or expression that specifies the fileref that is assigned to an external file.

libref

is a character constant, variable, or expression that specifies the libref that is assigned to a SAS library.

Optional Argument

search-ref

is a character constant, variable, or expression that specifies whether to search for a fileref or a libref.

F specifies a search for a fileref.
L specifies a search for a libref.

Details

PATHNAME returns the physical name of an external file or SAS library, or blank if fileref or libref is invalid.
If the name of a fileref is identical to the name of a libref, you can use the search-ref argument to choose which reference you want to search. If you specify a value of F, SAS searches for a fileref. If you specify a value of L, SAS searches for a libref.
If you do not specify a search-ref argument, and the name of a fileref is identical to the name of a libref, PATHNAME searches first for a libref. If a libref does not exist, PATHNAME then searches for a fileref.
The default length of the target variable in the DATA step is 200 characters.
You can assign a fileref to an external file by using the FILENAME statement or the FILENAME function.
You can assign a libref to a SAS library using the LIBNAME statement or the LIBNAME function. Some operating environments allow you to assign a libref using system commands.
Windows Specifics: Under some operating environments, filerefs can also be assigned by using system commands. For details, see the SAS documentation for your operating environment.

Example

This example uses the FILEREF function to verify that the fileref MYFILE is associated with an external file. Then it uses PATHNAME to retrieve the actual name of the external file:
data _null_;
   length fname $ 100;
   rc=fileref('myfile');
   if (rc=0) then
   do;
      fname=pathname('myfile');
      put fname=;
   end;
run;

See Also

Statements:
LIBNAME Statement in SAS Statements: Reference
FILENAME Statement in SAS Statements: Reference