Chapter Contents |
Previous |
Next |
FILENAME |
Category: | External File |
Syntax |
sysrc=FILENAME(fileref,filename<,device <,host-options<,dir-ref>>>); |
0 | successful |
0 | not successful |
Type: Numeric
''
) causes an error
condition. If the fileref is an SCL character variable that has a blank value,
a fileref will be generated for you.
Type: Character
Type: Character
Note: Some host operating systems do not support
pipes.
Type: Character
Type: Character
Type: Character
Details |
The name associated with the file or device is called a fileref (file reference name). Other SCL functions that manipulate external files and directories require that the files be identified by a fileref rather than by a physical filename. A system-generated fileref is not displayed in the FILENAME window.
The association between a fileref and a physical file lasts only for the duration of the current SAS session or until you use FILENAME to change or discontinue the association. You can de-assign filerefs by specifying a null string for the filename argument in FILENAME.
For more information about the arguments that you can use with FILENAME, see SAS Language Reference: Dictionary and the SAS documentation for your operating environment.
Operating Environment Information: The term directory in this description refers to an aggregate grouping of files that are managed by the host operating system. Different host operating systems identify such groupings with different names, such as directory, subdirectory, MACLIB, or partitioned data set. See the SAS documentation for your operating environment for details.
Under some operating systems, you can also use system commands to assign filerefs. Depending on the operating system, FILENAME may be unable to change or de-assign filerefs that are assigned outside of a SAS session.
See the SAS documentation for your host operating system for information about the system-dependent options that you can specify for options.
Examples |
Assign the fileref MYFILE to an external file:
/* Assign fileref MYFILE to the physical */ /* filename stored in the variable FNAME */ rc=filename('myfile',fname); if (rc ne 0) then _msg_=sysmsg();
Assign a system-generated fileref, stored in the variable FNAME, to the file whose physical name is in the control FNAME:
fname=' '; /* Assign a system-generated fileref to the */ /* filename stored in the variable FNAME */ rc=filename(fname,fname); if (rc) then _msg_=sysmsg(); else do; ...more SCL statements... end; /* De-assign the fileref */ rc=filename('myfile','');
Assign a fileref to an external file:
rc=filename('sharedfl','\ABC\XYZ\AUTOEXEC.SAS);
Assign a fileref for a pipe file with the output from the UNIX command LS, which lists the files in the directory /u/myid:
rc=filename('myfile','ls /u/myid','pipe');
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.