|Statements under UNIX|
|UNIX specifics:||device-type, external-file, host-options, and encoding-value|
|See:||FILENAME Statement in SAS Language Reference: Dictionary|
|Device Information in the FILENAME Statement|
|FILENAME fileref <device-type> 'external-file' <ENCODING='encoding-value'> <'host-options'><LOCKINTERNAL= AUTO | SHARED>;|
|FILENAME fileref device-type <'external-file'> <ENCODING='encoding-value'> <'host-options'><LOCKINTERNAL= AUTO | SHARED>;|
|FILENAME fileref ('pathname-1' ... 'pathname-n') <ENCODING='encoding-value'> <'host-options'><LOCKINTERNAL= AUTO | SHARED>;|
|FILENAME fileref directory-name <ENCODING='encoding-value'><LOCKINTERNAL= AUTO | SHARED>;|
|FILENAME fileref <access-method> 'external-file' access-information;|
|FILENAME fileref CLEAR | _ALL_ CLEAR;|
|FILENAME fileref LIST | _ALL_ LIST;|
Note: You cannot clear a fileref that is defined by an environment variable. Filerefs that are defined by an environment variable are assigned for the entire SAS session.See Using Environment Variables to Assign Filerefs in UNIX Environments for more information.
specifies a device for the output, such as a disk, terminal, printer, pipe, and so on. The device-type keyword must follow fileref and precede pathname. Device Information in the FILENAME Statement describes the valid device types. DISK is the default device type. If you are associating the fileref with a DISK file, then you do not need to specify the device type.
differs according to device type. Device Information in the FILENAME Statement shows the information appropriate to each device. Remember that UNIX filenames are case sensitive. See Specifying Pathnames in UNIX Environments for more information.
Note: If a filename has leading blanks, then they will be trimmed.
When you read data from an external file, SAS transcodes the data from the specified encoding to the session encoding. When you write data to an external file, SAS transcodes the data from the session encoding to the specified encoding.
For valid encoding values, see Encoding Values in SAS Language Elements in the SAS National Language Support (NLS): Reference Guide.
specifies the number of bytes that are physically written or read in one I/O operation. The default is 8K. The maximum is 1G-1. If you specify RECFM=S370VBS, then you should specify BLKSIZE=32760 in order to avoid errors with records longer than 255 characters.
controls the end of line/record delimiters in PC and UNIX formatted files. This option enables the sharing of UNIX and PC formatted files between the two hosts. The following values for the TERMSTR= option are valid:
If you are working on UNIX and reading a file that was created on a PC, specify TERMSTR=CRLF unless the file was created with the TERMSTR=NL option. If you are writing a file that will be read on a PC, specify TERMSTR=CRLF.
If you are working on a PC and reading a file that was created on UNIX, specify TERMSTR=NL unless the file was created with the TERMSTR=CRLF option. If you are writing a file that will be read on UNIX, specify TERMSTR=NL.
If RECFM=F, then the value for the LRECL= option determines either the number of bytes to be read as one record or the length of each output record. The output record is truncated or padded with blanks to fit the specified size.
If RECFM=V, then the value for the LRECL= option determines the maximum record length. Records that are longer than the specified length are divided into multiple records on output and truncated on input.
indicates that a new file is to be opened for output. If the file already exists, then it is deleted and re-created. If you specify OLD, then the previous contents of the file are replaced. NEW is the default.
binary format. The file consists of a stream of bytes with no record boundaries. N is not valid for the PIPE device type. If you do not specify the LRECL option, then by default SAS reads 256 bytes at a time from the file.
variable block with spanned records S370 record format (VBS). If you specify RECFM=S3270VBS, then you should specify BLDSIZE=32760 and LRECL=32760 in order to avoid errors with records longer than 255 characters.
specifies the SAS system locking that is to be used for the files that are listed in a FILENAME statement. LOCKINTERNAL can have one of the following values:
locks a file so that in a SAS session, if a user has Write access to a file, then no other users can have Read or Write access to the file. If a user has Read access to a file, no other user can have Write access to the file, but multiple users can have Read access.
locks a file so that in a SAS session, two users do not have simultaneous Write access to the file. The file can be shared simultaneously by one user who has Write access and multiple users who have Read access.
tells SAS not to perform buffered writes to the file on any subsequent FILE statement. This option applies especially when you are reading from or writing to a data collection device. As explained in SAS Language Reference: Dictionary, it also prevents buffered reads on INFILE statements.
are pathnames for the files that you want to access with the same fileref. Use this form of the FILENAME statement when you want to concatenate filenames. Concatenation of filenames is available only for DISK files, so you do not have to specify the device-type. Separate the pathnames with either commas or blank spaces. Enclose each pathname in quotation marks. Character Substitutions in Pathnames shows character substitutions you can use when specifying a pathname. If the fileref that you are defining is to be used for input, then you can also use wildcards as described in Using Wildcards in Pathnames (Input Only). Remember that UNIX filenames are case-sensitive.
specifies the directory that contains the files that you want to access. For more information, see Assigning a Fileref to a Directory (Using Aggregate Syntax).
can be CATALOG, SOCKET, FTP, SFTP, or URL. Device Information in the FILENAME Statement describes the information expected by these access methods.
differs according to the access method. Device Information in the FILENAME Statement shows the information appropriate to each access method.
Note: You cannot clear a fileref that is defined by an environment variable. Filerefs that are defined by environment variables are assigned for the entire SAS session.
writes to the SAS log the pathname of the specified fileref or, if you specify _ALL_, lists the definition for all filerefs that are currently defined. Filerefs defined as environment variables appear only if you have already used those filerefs in a SAS statement. If you are using the Bourne shell or the Korn shell, SAS cannot determine the name of a pre-opened file, so it displays the following string instead of a filename:
See Using Environment Variables to Assign Filerefs in UNIX Environments for more information.
File locking of external files is controlled at the FILENAME statement level by the LOCKINTERNAL option. If you use the AUTO (default) value for LOCKINTERNAL, then SAS locks a file exclusively for one user who has Write access, or SAS locks a file non-exclusively for multiple users who have Read access. For example, if a file is opened in UPDATE or OUTPUT mode, then all other access from internal processes will be blocked. If a file is opened in INPUT mode, then multiple users can read the file, but UPDATE and OUTPUT functions are blocked.
If you use the SHARED value for LOCKINTERNAL, then SAS allows one user Write access to a file as well as allowing multiple users to read the file.
The following table lists the relationship between device type or access method and the related external file.
|Device or Access Method||Function||External File|
|CATALOG||references a SAS catalog as an external file.||is a valid two-, three-, or four-part SAS catalog name followed by catalog options (if needed). See SAS Language Reference: Dictionary for information.|
|DISK||associates the fileref with a DISK file.||is either the pathname for a single file or, if you are concatenating filenames, a list of pathnames separated by spaces or commas and enclosed in parentheses. The level of specification depends on your location in the file system. Character Substitutions in Pathnames shows character substitutions that you can use when specifying a UNIX pathname.|
|DUMMY||associates a fileref with a null device.||None. DUMMY enables you to debug your application without reading from or writing to a device. Output to this device is discarded.|
|sends electronic mail to an address.||is an address and e-mail options. See Sending Electronic Mail Using the FILENAME Statement (EMAIL) for information.|
|FTP||reads from or writes to a file from any computer on a network that is running an FTP server.||
is the pathname of the external file on the remote computer followed
by FTP options. See
SAS Language Reference: Dictionary and Assigning Filerefs to Files on Other Systems (FTP, SFTP, and SOCKET Access Types) for information.
If you are transferring a file to UNIX from the z/OS operating environment and you want to use either the S370V or S370VB format to access that file, then the file must be of type RECFM=U and BLKSIZE=32760 before you transfer it. If you FTP to an z/OS computer, only one member of an z/OS PDS can be written to at a time. If you need to write to multiple members at the same time, an z/OS PDSE or a UNIX System Services directory should be used.
|PIPE||reads input from or writes output to a UNIX command.||is a UNIX command. See Printing and Routing Output for information.|
|PLOTTER||sends output to a plotter.||is a device name and plotter options. See Printing the Contents of a Window and Using the PRINTTO Procedure in UNIX Environments for information.|
|PRINTER||sends output to a printer.||is a device name and printer option. See Printing the Contents of a Window and Using the PRINTTO Procedure in UNIX Environments for information.|
|SFTP||reads from or writes to a file from any host computer that you can connect to on a network with an SSHD server running.||is the pathname of the external file on the remote computer, followed by SFTP options. See FILENAME Statement, SFTP Access Method and Assigning Filerefs to Files on Other Systems (FTP, SFTP, and SOCKET Access Types) for more information.|
|SOCKET||reads and writes information over a TCP/IP socket.||depends on whether the SAS application is a server application or a client application. In a client application, external-file is the name or IP address of the host and the TCP/IP port number to connect to, followed by any TCP/IP options. In a server application, external-file is the port number to create for listening, followed by the SERVER keyword, and then any TCP/IP options. See SAS Language Reference: Dictionary for information.|
|TEMP||associates a fileref with an external file stored in the Work library.||None|
|TERMINAL||associates a fileref with a terminal.||is the pathname of a terminal.|
|UPRINTER||sends output to the default printer that was set up through the Printer Setup dialog box.||None|
|URL||enables you to use the URL of a file to access it remotely.||is the name of the file that you want to read from or write to on a URL server. The URL must be in one of these forms:|
|WebDAV||enables you to use WebDAV (Web Distributed Authoring and Versioning) to read from or write to a file from any host machine that you can connect to on a network with a WebDAV server running.||is the name of the file that you want to read from or write to a WebDAV server. The external file must be in one of these forms:|