Associates a SAS fileref with an external file or an output device, disassociates a fileref and external file, or lists attributes of external files.
Valid in: | anywhere in a SAS program |
Restriction: | When SAS is in a locked-down state, the following FILENAME statement and access methods are not available. Your server administrator can re-enable this access method so that it is accessible in the locked-down state. For more information, see SAS Processing Restrictions for Servers in a Locked-Down State in SAS Language Reference: Concepts. |
Windows specifics: | Valid values for access-method; valid values for device-type; valid filenames for external-file; valid values for encoding; valid options in host-option-list |
See: | FILENAME Statement in SAS Statements: Reference |
This version is a simplified version of the FILENAME statement syntax. For the complete syntax and its explanation, see the FILENAME statement in FILENAME Statement in SAS Statements: Reference.
is any valid fileref, as discussed in “Using a Fileref” in the “Using External Files” section in SAS Companion for Windows.
enables you to read and write data from devices rather than files. For information about the SFTP access method, see Configuring SSH Client Software in UNIX and Windows. The following values are valid:
reads a SAS catalog as an external flat file.
reads text data from and writes text data to the clipboard on the host computer.
reads data from user-specified text by using the DATAURL access method.
reads data from and writes data to another application using Dynamic Data Exchange. For more information, see DDE Syntax within SAS.
reads data from and writes data to a disk file. Under Windows, DISK is the default for device-type.
displays information about the available hard drives (local and networked).
specifies a null output device. This value is especially useful in testing situations.
lets you send electronic mail programmatically from SAS. For more information, see Sending Email Using SAS.
Restriction | When SAS is in a locked-down state, the FILENAME statement, EMAIL access method is not available. Your server administrator can re-enable this access method so that it is accessible in the locked-down state. For more information, see SAS Processing Restrictions for Servers in a Locked-Down State in SAS Language Reference: Concepts. |
lets you access information about other machines using TCP/IP. TCP/IP software and a WINSOCK.DLL must be installed on your local machine. You must also be able to connect to a machine that can function as an FTP server. For more information about using the FTP access method, see the FILENAME statement in SAS Statements: Reference.
accesses files on a Hadoop Distributed File System (HDFS) whose location is specified in a configuration file.
writes data to a named pipe. For more information, see Using Named Pipes .
writes data to an unnamed pipe. For more information, see Using Unnamed Pipes .
Requirement | You must specify an external-file reference and the external-file reference must contain an absolute path and filename enclosed in quotation marks. |
indicates that you are accessing a plotter. Windows printing is not used. This device-type keyword is used solely in conjunction with SAS/GRAPH software.
indicates that you are accessing a printer file or device. By default, output is routed through Windows printing when you use this device-type keyword. For more information about altering your default printer, see SYSPRINT System Option: Windows.
accesses remote files by using the SFTP protocol.
lets you read and write information over a TCP/IP socket. TCP/IP software and a WINSOCK.DLL must be installed on your local machine. The SOCKET access method uses the nonblocking method of issuing socket requests. For more information about using the SOCKET access method, see the FILENAME statement and FILENAME function in SAS Statements: Reference and SAS Functions and CALL Routines: Reference.
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. A physical pathname is never shown to the user. If a physical pathname is specified, an error is returned. Files that are manipulated by the TEMP device can have the same attributes and behave identically to DISK files.
useful only with output, causes output to be sent to the Message Log window.
accesses remote files by using the URL access method.
accesses remote files by using the WebDAV protocol.
accesses ZIP files.
specifies the directory that contains the files that you want to access.
can be any valid Windows file specification that is enclosed in quotation marks. For more information, see Referencing External Files.
specifies permissions to set for the specified fileref.
A::<trustee_type>::<permissions>
Access permissions. No other values are supported.
u | user |
g | group (all groups) |
o | other (all others, including the user who generates the file.) |
The permission values take the values r (Read), w (Write), and x (Execute), in that order. If you do not want to grant one of these permissions, enter a - in its place (for example, r-x or rw-).
A::g::r-x
. To allow
all users to have Read access to a file, specify a permission value
of A::o::r--
. For example, specify that option
in the code as follows:
permission='A::o::r--'
specifies the encoding to use when reading from or writing to the external file. The value for ENCODING= indicates that the external file has a different encoding from the current session encoding.
names external I/O statement options that are specific to Windows. They can be any of the following:
is for use only with the PRINTER device type. Filename specifies a file destination to write to when you direct output to the fileref. Although the output is written to disk and not to the printer, the output is still formatted by using the printer driver that is associated with the printer that you specified with the external-file argument. For example,
filename groupHP printer "HP LaserJet 4si, 1st floor" altdest= "C:\My SAS Files\Printer output\out.prn";
out.prn
. No output is
actually sent to the printer when you use this fileref.
specifies the number of bytes that are physically read or written in an I/O operation. The default is 8K. The maximum is 1M.
is used only in the context of named pipes. This option indicates whether the client is to wait if no data is currently available. BLOCK is the default value.
is used only in the context of named pipes. This option indicates the type of pipe. BYTE is the default value.
is used only in the context of Dynamic Data Exchange (DDE). This option enables you to issue a remote command for applications that do not use the SYSTEM topic name. For more information, see Referencing the DDE External File and Controlling Another Application Using DDE.
controls how a communications port time-out is handled. A time-out occurs when no data is available at the communications port for a period of time, usually 60 seconds. The COMTIMEOUT= option can have the following values:
returns an end-of-file (EOF) character when a time-out occurs. This behavior is the default. The EOF character causes the current DATA step to terminate.
instructs the communications port to wait forever for data. This value overrides the time-out. In this case, no record is returned to the DATA step until data are available. This action can cause your program to go into an infinite loop, so use this value with caution.
returns a record length of 0 bytes when a time-out occurs. However, the DATA step does not terminate; it simply tries to read data again.
specifies the state of the DOS window when an application is opened using pipes. Valid states are:
MAX | opens the DOS window maximized |
MIN | opens the DOS window minimized |
NORMAL | opens the DOS window using the default for the machine. |
is used only in the context of named pipes and is valid only when you are defining the server. This option indicates that if an end-of-file (EOF) character is received from a client, the server should try to connect to the next client.
is used only in the context of Dynamic Data Exchange (DDE). For a complete description and an example of how to use this option, see Using the DDE HOTLINK.
is used in the context of I/O operations on variable record format files. When this option is specified, any occurrence of ^Z is interpreted as character data and not as an end-of-file marker.
specifies the record length (in bytes). Under Windows, the default is 32767. The value of record-length can range from 1 to 1,073,741,823 ( 1 gigabyte).
specifies that output should be appended to an existing file.
is used only in the context of Dynamic Data Exchange (DDE). This option enables you to use nontab character delimiters between variables. For more information about this option, see Using the NOTAB Option with DDE.
controls the record format. The following values are valid under Windows:
F | indicates fixed format. |
N | indicates binary format and causes the file to be treated as a byte stream. N is not valid for either the PIPE device type or the NAMEPIPE device type. If LRECL is not specified, the default value of 32767 bytes is used to read from or write to the file. |
P | indicates print format. |
S370V | indicates the variable S370 record format (V). |
S370VB | indicates the variable block S370 record format (VB). |
S370VBS | indicates the variable block with spanned records S370 record format (VBS). |
V | D | indicates variable format. This format is the default. |
is used only in the context of named pipes. This option specifies how long a named pipe client should wait for a busy pipe. The minimum (and default) value for seconds is 10.
is used only in the context of named pipes. This option specifies the mode of a named pipe. The default value is SERVER.
specifies the end-of-line character for the file. Use this option to share files between the UNIX and Windows operating environments. Here are the valid values:
Carriage return line feed. Use TERMSTR=CRLF to write files that are formatted for Windows. CRLF is the default.
Line feed. Use TERMSTR=LF to write files that are formatted for UNIX.
New line. Use TERMSTR=NL to write files that are formatted for UNIX.
filename read ('c:\myfiles\*.*','c:\myotherfiles\abc.dat'); data new; infile read; input; run;