Using Direct I/O

Introduction to Direct I/O

Direct I/O is a method for processing input and output files and is used in file handling. Direct I/O enables SAS to read files from and write files directly to storage devices without first going through the UNIX operating environment's read and write caches. You can use direct I/O for SAS files. Using direct I/O might improve system performance, depending on the number and types of jobs that you are running.
SAS uses three related options that affect direct I/O:
  • ENABLEDIRECTIO statement option
  • USEDIRECTIO= statement option
  • USEDIRECTIO= data set option
The ENABLEDIRECTIO option in the LIBNAME statement makes direct I/O processing available for data sets that are listed in the DATA statement. The libref that points to the data sets must have been defined in a LIBNAME statement that uses the ENABLEDIRECTIO option. Using ENABLEDIRECTIO itself does not turn on direct I/O.
A libref that is assigned to a directory with the ENABLEDIRECTIO option will not match another libref that is assigned to the same directory without the ENABLEDIRECTIO option. The two librefs will point to the same directory, but the files that are opened using the libref with ENABLEDIRECTIO can be read from and written to using direct I/O. Files that are opened using the other libref will be read from and written to using the regular disk I/O calls.
The USEDIRECTIO= data set option in the DATA statement or the USEDIRECTIO= statement option in the LIBNAME statement turns on direct I/O for data sets in which the ENABLEDIRECTIO statement option has been applied. Using USEDIRECTIO= without first applying the ENABLEDIRECTIO option has no effect on direct I/O in a data set.

Turning On Direct I/O

You can turn on direct I/O in two ways:
  • Use both the ENABLEDIRECTIO and USEDIRECTIO= options in the LIBNAME statement.
    This method opens for direct I/O all of the files that are referenced by the libref in the LIBNAME statement.
  • Use the ENABLEDIRECTIO option in the LIBNAME statement to render direct I/O available, and use the USEDIRECTIO= data set option in a DATA statement to turn on direct I/O functionality.
    This method opens for direct I/O only the data set where the option is used. The data set must be referenced by the libref in the LIBNAME statement.
For more information about these options and how they are used, see: