Previous Page | Next Page

SAS Component Language Dictionary

PATHNAME



Returns the physical name of a SAS data library or an external file
Category: External File

Syntax
Examples
Example 1: Using PATHNAME with the FILEREF Function
Example 2: Appending to a Pathname
Example 3: Concatenating Pathname
See Also

Syntax

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


Examples


Example 1: Using PATHNAME with the FILEREF Function

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;


Example 2: Appending to a Pathname

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


Example 3: Concatenating Pathname

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


See Also

FILENAME

FILEREF

FEXIST

FILEEXIST

Previous Page | Next Page | Top of Page