FILENAME Function: Windows

Assigns or deassigns a fileref for an external file, directory, or output device.

Category: External Files
Restriction: If the SAS session in which you are specifying the FILEEXIST function is in a locked-down state, and the pathname specified in the function has not been added to the lockdown path list, then the function fails and a file access error related to the locked-down data is not generated in the SAS log unless you specify the SYSMSG function.
Windows specifics: device types and host options
See: FILENAME Function in SAS Functions and CALL Routines: Reference

Syntax

Required Arguments

fileref

in a DATA step, specifies the fileref to assign to the external file. In a macro (for example, in the %SYSFUNC function), fileref is the name of a macro variable (without an ampersand) whose value contains the fileref to assign to the external file.

Under Windows, fileref can also be a Windows environment variable. The fileref or the environment variable that you specify must be enclosed in quotation marks.

filename

specifies the external file. Specifying a blank filename clears the fileref that was previously assigned.

Optional Arguments

device-type

specifies type of device or the access method that is used if the fileref points to an input or output device or location that is not a physical file. It can be any one of the devices that are listed in FILENAME statement device-type argument . DISK is the default device type.

host-options

are options that are specific to Windows. You can use any of the options that are available in the FILENAME statement. See the FILENAME statement host-option-list .

dir-ref

specifies the fileref that is assigned to the directory in which the external file resides.

Details

FILENAME returns a value of 0 if the operation was successful, and a nonzero number if the operation was not successful.

Example

For an example of using the FILENAME function, see Obtaining Directory Information.