Chapter Contents

Previous

Next
FILENAME

FILENAME



Associates a SAS fileref with an external file or a logical file device

Valid: anywhere in a SAS program
Windows specifics: Valid values for access-method; valid values for device-type; valid filenames for external-file; valid options in host-option-list


Syntax
Details
See Also

Syntax

FILENAME fileref <device-type> 'external-file' <host-option-list>;
FILENAME fileref device-type <'external-file'> <host-option-list>;
FILENAME fileref <device-type> ('directory-1'<,...directory-n'>) <host-option-list>;

Note:   This is a simplified version of the FILENAME statement syntax. For the complete syntax and its explanation, see the FILENAME statement in SAS Language Reference: Dictionary.  [cautionend]

fileref
is any valid fileref, as discussed in Using a Fileref.

For examples of using filerefs in member name syntax (also called aggregate syntax), see Assigning a Fileref to a Directory. For the rules the SAS System uses when accessing files through filerefs, see Understanding How Concatenated Directories Are Accessed.

Note:   The words CON, NUL, PRN, LPT1 - LPT9, and COM1 - COM9 are reserved words under Windows. Do not use them as filerefs.   [cautionend]

device-type
enables you to read and write data from devices rather than files. The following values are valid:

CATALOG
reads a SAS catalog as an external flat file.

COMMPORT
reads data from and writes data to a communications port.

DDE
reads data from and writes data to another application using Dynamic Data Exchange. For more information, see DDE Syntax within SAS.

DISK
reads data from and writes data to a disk file. Under Windows, DISK is the default for device-type.

DRIVEMAP
displays information about the available hard drives (local and networked).

DUMMY
specifies a null output device. This value is especially useful in testing situations.

EMAIL
lets you send electronic mail programmatically from the SAS System. For more information, see Sending Electronic Mail from within the SAS System.

FTP
lets you access information on other machines using TCP/IP. You must have TCP/IP software and a WINSOCK.DLL 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 on the using the FTP access method, see the FILENAME statement in SAS Language Reference: Dictionary.

NAMEPIPE
writes data to a named pipe. For more information, see Using Named Pipes.

PIPE
writes data to an unnamed pipe. For more information, see Using Unnamed Pipes.

PLOTTER
indicates that you are accessing a plotter. The Windows Print Manager is not used. This device-type keyword is used solely in conjunction with SAS/GRAPH software.

PRINTER
indicates that you are accessing a printer file or device. By default, output is routed through the Windows Print Manager when you use this device-type keyword. For more information on altering your default printer, see the system option SYSPRINT.

SOCKET
lets you read and write information over a TCP/IP socket. You must have TCP/IP software and a WINSOCK.DLL installed on your local machine. The SOCKET access method uses the nonblocking method of issuing socket requests. For more information on the using the SOCKET access method, see the FILENAME statement and FILENAME function in SAS Language Reference: Dictionary.

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

For an example of specifying a device type in the FILENAME statement, see Advanced External I/O Techniques.

Note:   The TAPE and TERMINAL device-type keywords (documented in SAS Language Reference: Dictionary) are not applicable to the Windows operating environment. If you use one of these device-type keywords in your SAS program under Windows, you receive an error message. Also, while the DISK device-type keyword is accepted under Windows, it is ignored because disk files are the default under Windows.  [cautionend]

external-file
can be any valid Windows file specification enclosed in quotes. (for more information, see Referencing External Files).

host-option-list
names external I/O statement options specific to Windows. They can be any of the following:

ALTDEST=filename
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 using the printer driver associated with the printer that you specified with the external-file argument. For example,
filename groupHP printer 
   "HP LaserJest 4si, 1st floor" 
   altdest=
      "C:\My SAS Files\Printer output\out.prn";
uses the printer driver associated with the named printer (an HP LaserJet 4si) to create the output in out.prn. No output is actually sent to the printer when you use this fileref.

BAUD=
sets the baud rate. This host-option is valid only if you specify the COMMPORT device-type keyword.

BITS=
sets the transmission bits. Values are 0-8. This host-option is valid only when you specify the COMMPORT device-type keyword.

BLKSIZE=block-size
BLK=block-size
specifies the number of btyes that are physically read or written in an I/O operation. The default is 8K. The maximum is 1M.

BLOCK | NOBLOCK
is used only in the context of named pipes. This option indicates whether the client is to wait if no data are currently available. BLOCK is the default value.

BYTE | MESSAGE
is used only in the context of named pipes. This option indicates the type of pipe. BYTE is the default value.

COMMAND
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.

COMTIMEOUT=value
controls how a communications port timeout is handled. A timeout occurs when no data are available at the communications port for a period of time, usually 60 seconds. The COMTIMEOUT= option can have the following values:
EOF returns an end-of-file (EOF) character when a timeout occurs. This is the default behavior. The EOF character causes the current DATA step to terminate.
WAIT instructs the communications port to wait forever for data. In other words, this value overrides the timeout. In this case, no record is returned to the DATA step until data are available. This can cause your program to go into an infinite loop, so use this value with caution.
ZERO returns a record length of 0 bytes when a timeout occurs. However, the DATA step does not terminate; it simply tries to read data again.

This host-option is valid only if you specify the COMMPORT device-type keyword.

CONSOLE=state
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.
This host-option is valid only if you specify the PIPE keyword.

DROPNULL=
is used to discard null bytes when received. The valid values are:
ON specifies to discard null bytes when received.
OFF specifies not to discard null bytes when received. OFF is the default value.

This host-option is valid only if you specify the COMMPORT device-type keyword. For example:

filename portin commport 'com1:' dropnull=off;

EOFCONNECT
is used only in the context of named pipes and is valid only when 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.

FLOW=
controls the transmission control flow. Values are: XONXOFF, DTRDSR, or RTSCTS. This host-option is valid only if you specify the COMMPORT device-type keyword.

HOTLINK
is used only in the context of Dynamic Data Exchange (DDE). For a complete description and an example of using this option, see Using the DDE HOTLINK.

LRECL=record-length
specifies the record length (in bytes). Under Windows, the default is 256. The value of record-length can range from 1 to 1,048,576 (1 megabyte).

MOD
specifies that output should be appended to an existing file.

NOTAB
is used only in the context of Dynamic Data Exchange (DDE). This option enables you to use non-tab character delimiters between variables. For more information about this option, see Using the NOTAB Option with DDE.

PARITY=
sets the parity check bit. Values are NONE, ODD, EVEN, MARK, or SPACE. This host-option is valid only if you specify the COMMPORT device-type keyword.

RECFM=record-format
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.
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 is the default.

The S370 values are valid with OS/390-style files only--that is, files that are binary, have variable-length records, and are in EBCDIC format. If you want to use a fixed-format OS/390 (formerly known as MVS) file, first copy it to a variable-length, binary OS/390 file.

RETRY=seconds
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.

RCONST=seconds
specifies the initial read time-out value in 0.001 of a second (1000 = 1 second). The default is 8 seconds. This host-option is valid only if you specify the COMMPORT device-type keyword.

RMULTI= seconds
specifies the subsequent read time-out value in 0.001 of a second (1000 = 1 second). This host-option is valid only if you specify the COMMPORT device-type keyword.

SERVER | CLIENT
is used only in the context of named pipes. This option specifies the mode of a named pipe. The default value is SERVER.

STOP=
sets the stop bit. Values are ONE, TWO, ONEHALF. This host-option is valid only if you specify the COMMPORT device-type keyword.

WCONST=seconds
specifies the initial time-out value in 0.001 of a second (1000 = 1 second). This host-option is valid only if you specify the COMMPORT device-type keyword.

WMULTI=seconds
specifies the subsequent time-out value in 0.001 of a second (1000 = 1 second). This host-option is valid only if you specify the COMMPORT device-type keyword.


Details

The FILENAME statement temporarily associates a valid SAS name with an external file or an output device. An external file is a file created and maintained in the Windows operating environment from which you need to read data.

See Also


Chapter Contents

Previous

Next

Top of Page

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