Chapter Contents

Previous

Next
FILENAME

FILENAME



Associates a SAS fileref with a device or an external file

Valid: anywhere
UNIX specifics: device-type, external-file, and host-options


Syntax
Device Information in the FILENAME Statement
See Also

Syntax

FILENAME fileref <device-type > 'external-file' <host-options>;
FILENAME fileref device-type <'external-file'> <'host-options'>;
FILENAME fileref CLEAR | _ALL_ CLEAR;
FILENAME fileref LIST | _ALL_ LIST;
FILENAME fileref ('pathname-1' ... 'pathname-n');

device-type
specifies a device for the output. It can be any one of the devices listed in Device Information in the FILENAME Statement. DISK is the default device type. If you are associating the fileref with a DISK file, you do not need to specify the device type.

'external-file'
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.

'pathname-1'...'pathname-n'
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. Concatenating 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.

'host-options'
are options specific to UNIX. They can be any of the following:

BLKSIZE=
BLK=
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, you should specify BLKSIZE=32760 to avoid errors with records longer than 255.

LRECL=
specifies the logical record length. Its meaning depends on the record format in effect (RECFM). The default is 256. The maximum length is 1G.

  • If RECFM=F, 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=N, the value for the LRECL= option must be at least 256.

  • If RECFM=V, 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.

  • If RECFM=S370VBS, you should specify LRECL=32760 to avoid errors with records longer than 255.

MOD
indicates that data written to the file should be appended to the file.

NEW|OLD
indicates that a new file is to be opened for output. If the file already exists, it is deleted and re-created. This is the default action.

RECFM=
specifies the record format. Values for the RECFM= option are
D default format (same as variable).
F fixed format. That is, each record has the same length. Do not use RECFM=F for external files that contain carriage-control characters.
N binary format. The file consists of a stream of bytes with no record boundaries.
P print format. On output, the SAS System writes carriage-control characters.
V variable format. Each record ends in a newline character.
S370V variable S370 record format (V).
S370VB variable block S370 record format (VB).
S370VBS variable block with spanned records S370 record format (VBS). If you specify RECFM=S3270VBS, then you should specify BLDSIZE=32760 and LRECL=32760 to avoid errors with records longer than 255.

Note:   To use the S370V, S370VB, or S370VBS format to access a file that was created under the OS/390 operating environment, the file must be of type RECFM=U.  [cautionend]

This option is used for both input and output.

UNBUF
tells the SAS System not to perform buffered writes to the file on any subsequent FILE statement. This option applies especially when reading from or writing to a data collection device. As explained in SAS Language Reference: Dictionary, it also prevents buffered reads on INFILE statements.

Device Information in the FILENAME Statement
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 catalog options (if needed). See SAS Language Reference: Dictionary for details.
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 blanks 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 you can use when specifying a UNIX pathname.
DUMMY associates a fileref with a null device. none. DUMMY allows you to debug your application without reading or writing to a device. Output to this device is discarded.
EMAIL sends electronic mail to an address. is an address and e-mail options. See Sending Electronic Mail from Within the SAS System (EMAIL) for more information.
FTP reads or writes to a file from any machine on a network that is running an FTP server. is the pathname of the external file on the remote machine followed by FTP options. See SAS Language Reference: Dictionary and Assigning Filerefs to Files on Other Systems (FTP and SOCKET access types) for details. If you are transferring a file from the OS/390 operating environment and you want to access that file using any of the S370 formats, then the file must be of type RECFM=U before you transfer it to UNIX.
PIPE reads input from or writes output to a UNIX command. is a UNIX command. See Routing Output for details.
PLOTTER sends output to a plotter. is a device name and plotter options. See Using PRTFILE and PRINT with a Filerefand Using the PRINTTO Procedure for details.
PRINTER sends output to a printer. is a device name and printer options. See Using PRTFILE and PRINT with a Filerefand Using the PRINTTO Procedure for details.
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, it 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 details.
TAPE associates a fileref with a tape. is the pathname for a tape device. The name specified should be the name of the special file associated with the tape device. See Processing Files on TAPE for more information.
TEMP associates a fileref with an external file stored in the WORK data library. none.
TERMINAL associates a fileref with a terminal. is the pathname of a terminal.
URL allows you to access remote files using the URL of the file. 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:
http://hostname/file
http://hostname:portno/file
XPRINTER sends output to the default printer that was set up through the Printer Setup dialog box. none.


See Also


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.