Chapter Contents

Previous

Next
FILENAME

FILENAME


Associates a SAS fileref with an external file

Language element: statement
Valid: anywhere in a SAS program
OpenVMS specifics: valid values for device-type; valid values for external-file; valid values for host-option-list


Syntax
Details
Reserved Filerefs
Device-Type Keywords
Host-Specific External I/O Statement Options
Using the KEY= Option
Using the KEYVALUE= Option
Using Compound Expressions
Using SAS Variables
Summary of External I/O Statement Options
Printer Options in the FILENAME and FILE Statements
Examples
Example 1: Associating a Fileref with an External File
Example 2: Using a File as Input to an INFILE Statement
Example 3: Using Printer Options
See Also

Syntax

FILENAME fileref <device-type>
'external-file' <host-option-list>;
FILENAME fileref device-type <'external-file'>
<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.  [cautend]

fileref
is any valid fileref and can be up to eight characters long. The first character must be a letter (A to Z), an underscore (_), a dollar sign ($), a pound sign (#), or an at sign (@). Subsequent characters can be any of these characters, or they can be numbers. Neither OpenVMS nor the SAS System distinguishes between uppercase and lowercase letters in filerefs or in filename specifications. This is a required argument.

The following are some examples of valid filerefs:

The following are some examples of invalid filerefs:

device-type
specifies an output device. For details about device types, see Device-Type Keywords. The device-type keyword must follow fileref and must precede external-file (if an external file is used).

'external-file'
can be any valid file specification in quotation marks. The file specification must be a valid OpenVMS pathname to the external file that you want to access; therefore, the level of specification depends on your location in the directory structure. The number of characters in the quoted string must not exceed the maximum filename length that OpenVMS allows (255 characters).

Under OpenVMS, you can specify concatenations of files when reading and writing external files from within the SAS System. Concatenated files consist of two or more file specifications, enclosed in quotation marks and separated by commas. The following is an example of a valid concatenation specification:


filename alldata 'test.data1, test.data2, 
                 test.data3';

For a complete discussion, see Using OpenVMS Pathnames to Identify External Files. For more information about valid OpenVMS pathnames, refer to OpenVMS User's Manual.

host-option-list
names any of the following external I/O statement options:
ALQ= KEYVALUE= NEW
CC= LINESIZE= OLD
DEQ= LRECL= PAGESIZE=
FAC= MBC= RECFM=
GSFCC= MBF= SHR=
KEY= MOD

These options control how the external file is processed and are specific to the OpenVMS environment. For information about these options, see Host-Specific External I/O Statement Options.

Many of the DCL print qualifiers are also supported as host options in the FILENAME and FILE statements. For details, see Printer Options in the FILENAME and FILE Statements.


Details

The FILENAME statement is significantly different from the LIBNAME statement. The FILENAME statement is for external files only and references a specific filename. The LIBNAME statement is for SAS files only, and it generally specifies directory- and subdirectory-level information only (except when you are assigning a libref for use with the XPORT, OSIRIS, or SPSS engines). Also, unlike a libref, you can associate a fileref with a file that does not yet exist; when you use the fileref in a FILE statement or command, the file is created according to your specifications.

You can choose to use only a directory name in the FILENAME statement (the directory must exist, except when doing a concatenation). You must then use the fileref and the filename in subsequent statements as discussed in Using Aggregate Syntax to Identify External Files. The SAS System supplies a default file type.


Reserved Filerefs

Under OpenVMS, the following are reserved filerefs (the items in parentheses are the SAS statements to which each applies):

DATALINES (INFILE)
specifies that input data immediately follow a DATALINES statement in your SAS stream. The only time you need to use the INFILE DATALINES fileref is when you want to use INFILE statement options to read in stream data.

LOG (FILE)
specifies that output lines produced by PUT statements are written to the SAS log. LOG is the default destination for output lines.

PRINT (FILE)
specifies that output lines produced by PUT statements are written to the procedure output file, the external file to which SAS procedure output is written.


Device-Type Keywords

When you specify a device-type in a FILENAME statement, the external-file argument is optional. If you do specify an external file, its meaning depends on which device type you specified. For example, the following SAS program sends the output file to the printer that is associated with the SYS$PRINT queue:


filename myfile printer;

data test;
   file myfile;
   put 'This is spooled to a printer.';
run;

The following are the valid device-type keywords and their meanings:

DISK
sends the output to a disk device. This is the default behavior if you do not specify any device-type keywords in the FILENAME statement. You must specify an external file with this keyword.

TERMINAL
sends the output to a terminal device. If you do not specify an external file, the output goes to the SYS$OUTPUT output stream. If you do specify an external file, the file specification is ignored and SYS$OUTPUT is still used.

If you are using the SAS windowing environment, the data are displayed in the DECterm window. If you are using the fileref for input, enter all input lines and then press CTRL-Z to return to the SAS windowing environment.

If you want to display and enter data in the same step, then issue two FILENAME statements and use one fileref for input and one for output.

PRINTER
spools the output to a printer queue. If you do not specify an external file, the output is sent first to a temporary file on disk and then to the SYS$PRINT queue. Then the disk file is deleted. If you do specify a file, the output is sent to that file and then sent to the SYS$PRINT queue. In this case, the disk file is not deleted. To send the output to a printer queue other than SYS$PRINT, use the QUEUE= option in the FILENAME or FILE statement. For information about printer options, see Printer Options in the FILENAME and FILE Statements.

PLOTTER
spools the output to a printer queue that has been assigned to a plotter. This keyword works the same as the PRINTER keyword except that the file format is valid for a plotter device. The file that is created is an OpenVMS print file; it has a variable record format, with a 2-byte, fixed-length control field.

For every record, the 2-byte control field is set to NULL, indicating no carriage control.

TAPE
sends the output to a tape device. You are responsible for allocating the tape drive and mounting the tape before output is sent to the device. If you do not specify an external file, the output is sent to the tape device that is associated with the logical name SASTAPE. If you do specify a file, the device portion of the filename must be a valid tape device.

TEMP
is a temporary file that can only be accessed through the logical name and is only available 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.

DUMMY
sends the output to NLA0: (the null device). If you specify an external file, the file specification is ignored. This device-type keyword is useful when you are debugging SAS programs. You can test your algorithms without actually writing output files.

These keywords are valid only in the FILENAME statement. However, a fileref for which you specified a device-type keyword can be used in the SAS windowing environment commands and in the FILE, INFILE, and %INCLUDE statements. In order to use these devices correctly, you must specify the device-type keyword in the FILENAME statement. (If you use a device specification only in the quoted file specification of a FILE or INFILE statement, the results are unpredictable.) For example, to correctly send output to the display, use the following statements:


filename myfile terminal;

data test;
   file myfile;
   put 'This is my test';
run;

By contrast, the following lines are incorrect and may yield unpredictable results:


data test2;
   file 'sys$output';
   put 'This may not work in all cases.';
run;

When you use the TERMINAL device type with the INFILE statement, you terminate input by pressing CTRL-Z.


Host-Specific External I/O Statement Options

The following external I/O statement options can be used in the FILE, INFILE, and FILENAME statements. Note that some of these options, such as ALQ=, have the same names as SAS data set options. Do not confuse the two types of options. You cannot use data set options with external files.

This list includes only options that are specific to the OpenVMS environment. For a complete list of external I/O statement options, see Summary of External I/O Statement Options and the statements chapter in SAS Language Reference: Dictionary.

The following descriptions include an explanation of the option, its valid and default values, and whether it is used for input, output, or both.

If the same option is used in both the FILENAME and FILE statements or in both the FILENAME and INFILE statements, the FILE or INFILE value takes precedence over the value used in the FILENAME statement.

ALQ=
specifies the number of blocks initially allocated to an external file when it is created. The value can range from 0 to 2,147,483,647. If the value is 0 (the default), the minimum number of blocks required for the given file format is used.

The ALQ= option (allocation quantity) is used for output and corresponds to the FAB$L_ALQ field in OpenVMS Record Management Services (RMS). For additional details, refer to Guide to OpenVMS File Applications.

BLKSIZE= | BLK=
is no longer supported in the OpenVMS operating environment.

CC=
specifies the carriage-control format of the SAS log and listing file. This option has three possible values:

FORTRAN
indicates FORTRAN carriage-control format. This is the default for print files.

PRINT
indicates OpenVMS print format.

CR
indicates OpenVMS carriage-return, carriage-control format. This is the default for nonprinting files.

Only SAS print files are affected by the CC= option. The CC= option is used for output.

The CC= option also exists as a SAS system option (see CC=). If you specify this option both as a system option and in the FILENAME or FILE statement, then SAS uses the value that you specified in the FILENAME or FILE statement.

DEQ=
specifies the number of blocks added when OpenVMS RMS automatically extends an external file during a write operation. The value can range from 0 to 65,535. The default value is 0, telling OpenVMS RMS to use the process's default value. A large value results in fewer file extensions over the life of the file; a small value results in numerous file extensions over the life of the file. A file with numerous file extensions may be noncontiguous, thereby slowing record access.

The DEQ= option (default file extension quantity) is used for output and corresponds to the FAB$W_DEQ field in OpenVMS RMS. For additional details, see Guide to OpenVMS File Applications.

FAC=
overrides the default file access attributes used for external files. Use this option to indicate the level of access you want to allow for an external file. You can allow read, write, update, and delete access (as well as no access). By default with external files, files opened for input allow read access, files opened for output allow write access, and files opened for update allow read and write access. The form of the FAC= option is

FAC=access-option-list
where access-option-list can be one of the following:
DEL specifies delete access.
GET specifies read access.
PUT specifies write access.
UPD specifies update access.

You can combine these values in any order. For example, specifying the following indicates you want delete, read, and write access:


fac=(del,get,put)

By also specifying the SHR= option, you can allow other users concurrent access to an external file, either through a separate SAS session or with another application. To allow sharing, you must include the values for FAC= in the list of values for SHR= (but the reverse is not true). For more information, see the description of the SHR= option later in this section.

The FAC= option (file access) can be used for both input and output and corresponds to the FAB$B_FAC field in OpenVMS RMS or the ACCESS attribute when using File Definition Language (FDL). For additional details on file sharing, see Guide to OpenVMS File Applications.

GSFCC=
specifies the file format of graphic stream files (GSF files). When specified on the FILENAME statement, it affects only the GSF files created using that fileref. The accepted values are
PRINT creates a GSF file. It is a VFC format file with carriage control set to null. These files can be used with most utilities with the exception of some file transfer protocols, such as Kermit. This is the default value for this option.
CR creates a carriage return carriage control file.
NONE creates a file with no carriage control. This format is useful if you plan to download the file to a personal computer.

KEY=
specifies which key the SAS System uses to read the records in an RMS file with indexed organization. The KEY= option is always used with the KEYVALUE= option. For details, see Using the KEY= Option and Using the KEYVALUE= Option.

KEYVALUE=
specifies the key value with which to begin reading an indexed file. For details, see Using the KEYVALUE= Option.

LINESIZE=
specifies the line size for input or output. The value can range from 10 to 32,767. The default is 80 for interactive jobs (interactive line mode and the SAS windowing environment) and 132 for noninteractive and batch jobs for print files.

This option also exists as a SAS system option (see LINESIZE=). If this option is used both as a system option and in the INFILE or FILE statement, the SAS System uses the value given in the INFILE or FILE statement.

LRECL=
specifies the record length of the output file. If you do not specify a record length, the default is varying length records. For input, the existing record length is used by default. If the LRECL= option is used, the input records are padded or truncated to the specified length.

The maximum LRECL= value for the OpenVMS system is 65535; however, errors can be produced if you attempt to access certain file types with an LRECL of less than 65535. Therefore, you should use the maximum LRECL values for the various file types provided in Maximum LRECL Values for File Types.

Because the FLOWOVER option on the FILE statement is the default, lines that are longer than the length specified by the LRECL= option are split.

When accessing unlabeled tapes, you must use LRECL=. The minimum value in this case is 14. For more information, see Reading from an Unlabeled Tape.

The LRECL= option is used for both input and output.

Maximum LRECL Values for File Types
File Organization Record Format Maximum LRECL Value
Sequential Fixed length 32,767
Sequential (disk) Variable length 32,765
Sequential (disk) VFC 32,767-FSZ
Sequential (disk) Stream 32,767
Sequential (disk) Stream-CR 32,767
Sequential (disk) Stream-LF 32,767
Sequential (ANSI Tape) Variable length 9,995
Sequential (ANSI Tape) VFC 9,995-FSZ
Relative Fixed length 32,255
Relative Variable length 32,253
Relative VFC 32,253-FSZ
Indexed, Prolog 1 or 2 Fixed length 32,234
Indexed, Prolog 1 or 2 Variable length 32,232
Indexed, Prolog 3 Fixed length 32,224
Indexed, Prolog 3 Variable length 32,224

FSZ represents the size, in bytes, of the fixed control area in a record with VFC record format.

MBC=
specifies the size of the I/O buffers that OpenVMS RMS allocates for a particular file. The value can range from 0 to 127 and represents the number of blocks used for each buffer. By default, this option is set to 0 and the default values for the process are used.

The MBC= option (multiblock count) is used for both input and output to control the allocation for a particular file. If you want to control the allocation size for all the external files used during the current SAS session, you can use the MBC= option in every FILE, FILENAME, or INFILE statement. You can also use the DCL SET RMS_DEFAULT command to specify a process default, and let the SAS System value default to the process's default values.

The MBC= option corresponds to the RAB$B_MBC field in OpenVMS RMS or the CONNECT MULTIBLOCK_COUNT attribute when using FDL. This option is not supported for DECnet operations. For additional details, see Guide to OpenVMS File Applications.

MBF=
specifies the number of I/O buffers you want OpenVMS RMS to allocate for a particular file. The value can range from 0 to 127 and represents the number of buffers used. By default, this option is set to 2 buffers. If a value of 0 is specified, the default value for the process is used.

The MBF= option (multibuffer count) is used for both input and output to control the number of buffers allocated for a particular file. If you want to control the number of buffers allocated for all the external files used during the SAS session, you can use the MBF= option in every FILE, FILENAME, or INFILE statement. The DCL SET RMS_DEFAULT command can be used to specify a process default. Then, you can let the SAS System value default to the process's default values.

The MBF= option corresponds to the RAB$B_MBF field in OpenVMS RMS or the CONNECT MULTIBUFFER_COUNT attribute when using FDL. This option is not supported for DECnet operations. For additional details, see Guide to OpenVMS File Applications.

MOD
opens the file referenced for append. This option does not take a value. An existing file of the name given in the FILENAME or FILE statement is opened and new data appended to the end.

NEW
opens a new file for output. This option does not take a value. This is the default action for files referenced by a FILE statement. Under OpenVMS, this option is synonymous with the OLD option.

OLD
opens a new file for output. This option does not take a value. This is the default action for files referenced by a FILE statement. Under OpenVMS, this option is synonymous with the NEW option.

PAGESIZE=
specifies the page size for output. The default is the display setting for interactive jobs (interactive line mode and the SAS windowing environment) and 60 for noninteractive and batch jobs. The value can range from 20 to 500.

This option also exists as a SAS system option (see PAGESIZE=). If this option is used both as a system option and in the FILE statement, the SAS System uses the value given in the FILE statement.

RECFM=
specifies the record format of the output file. Values for the RECFM= option are
F specifies fixed length.
V specifies variable length.
D specifies you are accessing unlabeled tapes with the PUT and INPUT DATA step statements. For more information, see Reading from an Unlabeled Tape.

If the RECFM= option is not used, the value defaults to V for output files. For input files, the default value is the record format of the file.

This option is used for both input and output.

SHR=
overrides the default file-sharing attributes used for external files. With this option, you can indicate the access level you want to give other users. You can allow read, write, update, and delete access (as well as no access). By default with external files, files opened for input allow shared read access, and files opened for output or update do not allow shared access.

However, you can allow other users to have read and write access to a file that you are opening for input only. To accomplish this, use the SHR= option. The syntax of the SHR= option is


SHR=share-option-list
where share-option-list can be one of the following:
DEL specifies delete access.
GET specifies shared read access.
NONE specifies no shared access.
PUT specifies shared write access.
UPD specifies update access.

You can combine these values in any order. For example, specifying the following indicates you want shared delete, read, and write access:


shr=(del,get,put)

To allow shared access, the values for FAC= must be included in the list of values for SHR= (but the reverse is not true).

This option corresponds to the FAB$B_SHR field in OpenVMS RMS or the SHARING attribute when using FDL. For more information about file sharing, see Guide to OpenVMS File Applications.

The SHR= option is used for both input and output.


Using the KEY= Option

The KEY= option is used for input. It is always used with the KEYVALUE= option. A key is a record field that identifies the record to help you retrieve the record in an indexed file. The two types of keys are primary and alternate. Data records are stored in the file in the order of their primary key. Alternate keys (also called secondary keys) create alternate indexes in the file. The alternate index can then be used to process the records in order of the alternate key. The only difference between the primary key and the alternate key is that the records are actually stored in the order of the primary key, whereas the alternate key provides a means of accessing them.

The key number is zero-based, so KEY=0 (the default) specifies that the records be read in sorted order by the primary key. KEY=1 specifies the use of the first secondary key to access the records.

To use the SAS System to write to an indexed file, you can either create an empty indexed file or use any existing indexed file. If you create an empty indexed file, use FDL to specify the file characteristics, including the type and location of primary and secondary keys. (For more information on FDL, see OpenVMS File Definition Language Facility Manual.) The following is an example program:


/*-------------------------------------------*/
/* This SAS program accesses an empty        */
/* indexed file that has been previously     */
/* created. The data are appended to the     */
/* file. Primary key #0 is of type character */
/* and is in bytes 0-2. Secondary key #1 is  */
/* of type character and is in bytes 3-5.    */
/*-------------------------------------------*/
filename myfile 'indexed.dat';
   /* Load the indexed file, primary key in */
   /* sorted order.                         */
data _null_;
   file myfile mod;
   put 'aaaccc';
   put 'bbbaaa';
run;
   /* Print out in primary key sorted order. */
data _null_;
      /* Key=0 is the default. */
   infile myfile;
   input first $3. second $3.;
   put first= second=;
run;

This program produces the following output:


first=aaa second=ccc
first=bbb second=aaa

In contrast, consider setting KEY=1 as in the following example:


/* Print out in secondary key sorted order. */
data _null_;
   infile myfile key=1;
   input first $3. second $3.;
   put first= second=;
run;

This program produces the following output:


first=bbb second=aaa
first=aaa second=ccc

All keys are defined in RMS when the file is created. For more information about defining and using keys in an indexed file, see Guide to OpenVMS File Applications.


Using the KEYVALUE= Option

The KEYVALUE= option is always used with the KEY= option, which specifies the key used by the SAS System to read the records in an RMS file with indexed organization. When you use the KEYVALUE= option, the file is input sequentially, beginning with the value you specified. It is similar to the FIRSTOBS= option used with a sequential-format file. You can specify a SAS variable name with the KEYVALUE= option to drive random reads from the file. The KEYVALUE= option is used for input.

Valid forms of the KEYVALUE= option are


KEYVALUE operator value
   AND KEYVALUE operator value

KEYVALUE=SAS-variable
where operator can be one of the following:
< less than
<= less than or equal to
> greater than
>= greater than or equal to.

where value can be one of the following data types:

The key specified in the KEY= option is used with the KEYVALUE= option. The defined order of the key specified must match the direction of the operator given in the KEYVALUE= option. For example, if the key is an ascending order key, the < and <= operators are invalid operators. When the value of KEYVALUE= is a constant value, the file is processed sequentially by key, beginning with the given value. When the value of KEYVALUE= is a SAS variable, the first record with a key satisfying the criterion of the KEYVALUE expression is read from the file. Note that the SAS variable value must match the key value of one of the records exactly or an end-of-file condition occurs.

The data type of the key specified in the KEY= option must also correspond to the type given as the value for the KEYVALUE= option. The following RMS data types are supported by the KEYVALUE= option:

The SAS System converts an integer value to the correct format of the supported numeric types. Character string values are not changed when used for the character type.

When you use date-time values, the data are stored in signed 8-byte binary RMS key fields. Use the VMSTIMEF. format to convert SAS date-time values to signed 8-byte binary values. When you access records through a date-time value key using the KEYVALUE=SAS-variable option, the SAS variable must have one of the following SAS formats or informats associated with it:
DATEw.
DATETIMEw.
DDMMYYw.
JULIANw.
MMDDYYw.
MONYYw.
YYMMDDw.
YYQw.

A format or informat must be associated with the SAS variable because neither the variable value nor the field value within the record indicates that the data represent date-time values. For more information about these formats and informats, refer to SAS Language Reference: Dictionary.

Suppose you want to input an indexed file that has an alternate key defined as a signed 4-byte integer in descending sort order. You can process only the records with the values less than 5,000 with the following DATA step:


filename in 'indexed.dat' key=2 keyvalue<5000;
data _null_;
   infile in;
   input name $9. num;
   put name num;
run;

Using Compound Expressions

You may further restrict the number of records read by using a compound KEYVALUE expression. For example, suppose you want to input an indexed file that has a primary key defined as a signed 2-byte integer in ascending sort order. You can retrieve records with key values between -10 and 10 inclusive with the following FILENAME statement:


filename in 'indexed.dat' keyvalue>=-10 and
   keyvalue<=10;

When given a compound KEYVALUE expression, the SAS System reads records from the input file until a record is read with a key exceeding the upper boundary, which is 10 in this example, or until the end of file is reached. Note that the AND construct has an associative property; the order of the KEYVALUE options can be reversed and the meaning preserved. However, the operators still must match the key sort order, so the following DATA step using the same indexed file described in the earlier example generates an error:


data wrong;
   infile 'indexed.dat' keyvalue<=-10 and
      keyvalue>=10;
   input num name $9.;
   put name num;
run;

This DATA step generates the following error and warning messages:


ERROR: Specified key on indexed file is 
       defined as ascending but <, <= or 
       = was used in KEYVALUE option.
NOTE: The SAS System stopped processing 
      this step because of errors.

WARNING: The data set WORK.WRONG may be 
         incomplete.  When this step was 
         stopped there were O observations 
         and 1 variables.

Using SAS Variables

Using a SAS variable name as the value of the KEYVALUE= option enables you to randomly access records in the indexed file. In the previous examples of using the KEYVALUE= option, the input file was sequentially accessed. You can use any SAS variable with the KEYVALUE= option that matches the type of the key in question. When the SAS System reads from the file, it reads the first record with the key value that matches the value of the SAS variable.

For example, suppose you have a SAS data set named SALES that has three variables: SALESREP, ITEMNO, and QUANTITY. This data set contains the number of items each salesperson sold during the last month. You also have an indexed file keyed by the item numbers of the products the company sells. Stored in each record is the price of the item. Using these two files, the SAS System can easily generate a report of the revenue generated by each salesperson:


filename parts 'inventory.idx' key=0;
filename report 'revenue.lis';
data revenue;
   set sales;
   infile parts keyvalue=itemno;
   input itemno price;
   revenue=quantity*price;
   output @5 salesrep @30 itemno 
          @50 revenue dollar3.2;
   stop;
run;

This sample program match-merges the observations in SALES with the records in the indexed file by item number to produce the reports. A KEYVALUE= option with a SAS variable name can be used only with the equal sign (=) operator and cannot be used in compound KEYVALUE expressions.

Note that in the previous example, the DATA step is driven entirely by the SET statement. The DATA step terminates when all records from the data set SALES have been processed. It is possible to use the SAS variable form of the KEYVALUE= option with other types of control mechanisms. In the following example, an iterative DO loop determines the set of records read from an indexed file:


data example2;
   do i=1 to 20 by 2;
      infile myfile key=0 keyvalue=i;
      input var1 var2 var3 ...;
      /* .... variable processing ... */

      output var1 var2 var3 ...;
   end;
   stop;
run;

In this example, the DO loop is used to read every other record from MYFILE. Note that the STOP statement terminates the DATA step and closes the input file. Because the KEYVALUE=I option reads only those records specified in the DO statement, the SAS System cannot read an end-of-file indicator as it would if it were reading the file sequentially. Without the STOP statement to end the DATA step, the SAS System can get into an infinite loop by accessing the same index file repeatedly.

For more information about indexed files and keys, refer to Guide to OpenVMS File Applications.


Summary of External I/O Statement Options

Summary of External I/O Statement Options lists alphabetically all available external I/O statement options, including both portable options and options that are specific to the OpenVMS environment. The Use column indicates whether the option is used for input, output, or both. The support of the option in the FILENAME statement is host-specific. Options that are used with the FILENAME statement are not documented in SAS Language Reference: Dictionary.

Summary of External I/O Statement Options
Option Use Option Use
ALQ= ** output LINESIZE= * input, output
CC= ** output LRECL= * input, output
COLUMN= *** input, output MBC= ** input, output
DELIMITER= *** input MBF= ** input, output
DEQ= ** output MISSOVER *** input
DROPOVER *** output MOD * output
END= *** input N= *** input, output
EOF= *** input NEW ** output
EXPANDTABS *** input NOTITLES *** output
FAC= ** input, output OBS= *** input
FILENAME= *** input, output OLD * output
FILEVAR *** input, output PAD *** input, output
FIRSTOBS= *** input PAGESIZE= * output
FLOWOVER *** input, output PRINT *** input, output
GSFCC ** output RECFM= * input, output
HEADER= *** output SHR= ** input, output
KEY= ** input SHAREBUFFERS *** input
KEYVALUE= ** input START= *** input
LENGTH= *** input STOPOVER *** input, output
LINE= *** output UNBUFFERED *** input
*This option is also documented in SAS Language Reference: Dictionary.

**All the information for this option is contained in this document.

***This option is completely documented in SAS Language Reference: Dictionary.



Printer Options in the FILENAME and FILE Statements

Many of the DCL print qualifiers are supported as host options in the FILE and FILENAME statements. If the same option is used in both the FILE and FILENAME statements, the FILE statement value overrides the FILENAME statement value. You send a file to a printer by using the PRINTER or PLOTTER device-type keyword in the FILENAME statement.

A complete list of supported options follows. For more information about the meanings of specific options, refer to OpenVMS DCL Dictionary.

AFTER="quoted-string"
specifies a time after which the file can be printed. The time can be specified as absolute time or a combination of absolute and delta times and must be enclosed in double quotation marks.

BURST=<ALL | NO>
specifies a burst page or not. The default value is NO.

CHAR=(,,,)
lists characteristics for the printer. The list can be one item or a group of items enclosed by parentheses. No spaces are allowed in the list.

COPIES=n
specifies the number of copies to print. The default value is 1.

FEED=<YES | NO>
specifies whether to perform a form feed at the end of the page. The default value is YES.

FLAG=<ALL | NO>
specifies whether to print a flag page preceding each file. The default value is NO.

FORM=type
defines the form name or number used.

HDR=<YES | NO>
controls whether a header line is printed at the top of each page. The default value is NO.

NAME=quoted-string
specifies the name of the submitted job shown when you issue a SHOW QUEUE command. The default is the filename. The quoted-string argument can contain spaces.

NOTE=quoted-string
specifies a message to appear on the flag page. The quoted-string argument can contain spaces.

NOTIFY=<YES | NO>
controls whether to notify the user when the job is finished. The default value is NO.

PARAM=<">(,,,)<">
sends a list of up to eight parameters to the printer device. The PARAM= value can be one item without parentheses, or a group of items enclosed by parentheses. If the value contains blanks or nonalphanumeric characters, enclose the entire value argument in single or double quotation marks.

PASSALL=<YES | NO>
specifies whether all formatting is bypassed and sent to the device driver with formatting suppressed. The default value is NO.

QUEUE=<">queue-name<">
specifies the name of the printer queue to send the job to. If this option is not used, the job is submitted to the SYS$PRINT queue. If the queue name contains characters not recognized by the SAS System, it must be enclosed in single quotation marks; for example, SYS$PRINT must be enclosed in quotation marks, but CLXYJ31 does not need to be. The queue-name argument cannot contain any spaces.

RESTART=<YES | NO>
restarts the job after a crash. The default value is YES.

SETUP=(,,,)
sets up module names to extract from the device control library. The list can be a single item or a group of items enclosed by parentheses.

SPACE=<1 | 2>
specifies double- or single-spacing. The default value is single.

TRAILER=<ALL | NO>
prints a trailer page at the end of the file. The default value is NO.


Examples

Example 1: Associating a Fileref with an External File

In this example, the FILENAME statement associates the fileref PGMSAS with an external file that contains a SAS program. PGMSAS is then used as the fileref in the %INCLUDE statement to read a file that contains SAS statements.


filename pgmsas '[yourdir]prog1.sas';
%include pgmsas;

Example 2: Using a File as Input to an INFILE Statement

Consider the following FILENAME statement:


filename myfile '[mydir]';

If you want to use a file in [MYDIR] named SCORES02.DAT as input to an INFILE statement, issue the following statement:


infile myfile(scores02);

The SAS System assumes a file type of .DAT in the INFILE statement.

If you do not specify a file type in the external file specification, the default file type is .DAT. For example, the following FILENAME statement associates the fileref MYFILE with a file named SURVEY.DAT:


filename myfile 'survey';

Example 3: Using Printer Options

The following statement sends a copy of the file A.LIS to the CLXYJ31 queue, holds it until 2:00 p.m., and then prints two copies:


filename x printer 'a.lis' queue=clxyj31 
                           after="14:00:00" copies=2;

The following statement creates the file A.LIS but does not send it to the printer because the PRINTER device-type keyword is not used. The AFTER= option is ignored.


filename x 'a.lis' after="14:00:00";

The following statement sends the file A.LIS to the SYS$PRINT queue, holding it until 2:30 p.m.:


filename x printer 'a.lis' after="14:30:00";

The following statement creates a temporary file called SAS0000n and sends it to the SYS$PRINT queue. The file is deleted after printing.


filename x printer;

The following statement creates the file CLXYJ31.DAT and sends it to the SYS$PRINT queue. The file is not deleted after printing.


filename x printer 'clxyj31';

As a final example, the following lines create a file A.LIS and send it to the SYS$PRINT queue. The job name submitted is MYFILE.


filename x printer 'a.lis';
data a;
   file x name="myfile";
   . . . more SAS statements . . .
run;

See Also


Chapter Contents

Previous

Next

Top of Page

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