SAS Features That Optimize Performance

The following are some additional features of SAS that you can control to improve system performance and make efficient use of your computer's resources. For additional information about optimizing SAS performance, see the chapter on optimizing system performance in SAS Language Reference: Concepts.
  • Create SAS data sets instead of accessing flat ASCII files. SAS can access a SAS data set more efficiently than it can read flat files.
    Also, you should convert existing data sets that you use frequently to SAS 9.4 format.
  • In your SAS code, use IF-THEN-ELSE conditional structures instead of multiple IF-THEN structures. When one condition in the IF-THEN-ELSE structure is met, control returns to the top of the structure (skipping the ELSE clause, which might contain subsequent IF-THEN structures). With multiple IF-THEN structures, each condition must be checked.
  • When using arrays, make them _TEMPORARY_ if possible. This action requires less memory and less time for memory allocation.
  • Use programming structures that reduce file I/O, the most time-intensive aspect of SAS processing. Some ideas for reducing file I/O are:
    • Use the WHERE statement in a procedure to reduce extra data processing.
    • Use indexed data sets to speed access to the desired observations.
    • Use the SQL procedure to subset and group your data.
  • Experiment with the value of the CATCACHE system option, which specifies the number of SAS catalogs to keep open at one time. By default, no catalogs are cached in memory (and CATCACHE is set to 0). Caching catalogs is an advantage if one SAS application uses catalogs that are subsequently needed by another SAS application. The second SAS application can access the cached catalog more efficiently.
    Note: Storing catalogs in memory can consume considerable resources. Use this technique only if memory issues are not a concern.
  • Store your data sets in a compressed format (using the COMPRESS data set option). This action can improve the performance of your SAS application, though it might require more CPU time to decompress observations as SAS needs them. The COMPRESS data set option is described in the data set options section of SAS Data Set Options: Reference.
  • If you specify the Scatter-read/Gather-write system option, SGIO, SAS bypasses intermediate buffer transfers when reading or writing data. SAS reads ahead the number of pages specified by the BUFNO system option and place the data in memory before it is needed. When the data is needed it is already in memory, and is in effect a direct memory access. Different values for the BUFNO system option should be tried for each SAS job to find the maximum performance benefit. For more information see Achieving Better I/O Throughput Using SGIO in the Microsoft Windows Environment
    Scatter–read / gather–write is active only for SAS I/O opened in INPUT, OUTPUT mode, and UPDATE mode if the access pattern is sequential. If any SAS I/O files are opened in UPDATE or RANDOM mode, SGIO is inactive for that process. Compressed and encrypted files can also be read ahead using scatter-read/gather-write. For more information about the SGIO system option, see SGIO System Option: Windows .