Previous Page | Next Page

Functions and CALL Routines under z/OS

FILENAME Function: z/OS

Assigns or deassigns a fileref for an external file, a directory, or an output device.
Category: External Files
z/OS specifics: host options, devices
See: FILENAME Function in SAS Language Reference: Dictionary

See Also


FILENAME(fileref,filename<,device <,host-options>>)


in a DATA step, specifies the fileref to assign to an external file. In a DATA step, fileref can be a character expression, a string enclosed in quotation marks, or a DATA step variable whose value contains the fileref. If fileref is a literal fileref name, it must be in quotation marks. If fileref is the name of a character variable whose value is a fileref name, it must not be quoted.

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. In a macro, fileref can be any expression.


specifies the external file. Specifying a blank filename (' ') deassigns the fileref that was previously assigned.


specifies the type of device if the fileref points to an output device rather than to a physical file:


specifies a disk.


specifies that output to the file is discarded.


specifies an unnamed pipe.


specifies an unbuffered graphics output device.


specifies a printer or printer spool file.


specifies the user's terminal.


specifies a tape drive.


creates a temporary file that exists only as long as the filename is assigned. The temporary file can be accessed only through the logical name and is available only while the logical name exists. If a physical pathname is specified, an error is returned. Files manipulated by the TEMP device can have the same attributes and behave identically to DISK files.


are host-specific options that can be specified in the FILENAME statement. These options can be categorized into several groups. For details, see the following sections:

You can specify host options in any order following the file specification and the optional device specification. When specifying more than one option, use a blank space to separate each option. Values for options can be specified with or without quotation marks. However, if a value contains one of the supported national characters ($, #, or @), the quotation marks are required.


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

See Also

Previous Page | Next Page | Top of Page