SAS Component Language Dictionary |
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); |
contains the physical name of an external file or a SAS data library, or a blank if fileref is invalid.
is the fileref assigned to an external file or a SAS data library.
Examples |
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=;
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=;
path=('/u/sasccf','/u/sasshh') path=('/u/sasccf','/u/sasshh')
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.