OBSBUF= Data Set Option

Determines the size of the view buffer for processing a DATA step view.

Valid in: DATA step and PROC steps
Category: Data Set Control
Restriction: Valid only for a DATA step view

Syntax

OBSBUF=n

Syntax Description

n

specifies the number of observations that are read into the view buffer at a time.

Default 32K bytes of memory are allocated for the default view buffer, which means the default number of observations that can be read into the view buffer at one time depends on the observation length. Therefore, the default is the number of observations that can fit into 32K bytes. If the observation length is larger than 32K bytes, then only one observation can be read into the buffer at a time.
Tip To determine the observation length in bytes, use PROC CONTENTS for the DATA step view.
CAUTION:
The maximum value for the OBSBUF= option depends on the amount of available memory.
If you specify a value so large that the memory allocation of the view buffer fails, an out-of-memory error results.

Details

The OBSBUF= data set option specifies the number of observations that can be read into the view buffer at a time. The view buffer is a segment of memory that is allocated to hold output observations that are generated from a DATA step view. The size of the buffer determines how much data can be held in memory at one time. OBSBUF= enables you to tune the performance of reading data from a DATA step view.
The view buffer is shared between the request that opens the DATA step view (for example, a SAS procedure) and the DATA step view itself. Two computer tasks coordinate between requesting data and generating and returning the data as follows:
  • When a request task (such as a PRINT procedure) requests data, task switching occurs from the request task to the view task. This action executes the DATA step view and generates the observations. The DATA step view fills the view buffer with as many observations as possible.
  • When the view buffer is full, task switching occurs from the view task back to the request task in order to return the requested data. The observations are cleared from the view buffer.
The size of the view buffer determines how many generated observations can be held. The number of generated observations determines how many times the computer must switch between the request task and the view task. For example, OBSBUF=1 results in task switching for each observation. OBSBUF=10 results in 10 observations being read into the view buffer at a time. The larger the view buffer, the less task switching is needed to process a DATA step view, which can speed execution time.
To improve efficiency, determine how many observations fit in the default buffer size, and then set the view buffer so that it can hold more generated observations.
Note: Using OBSBUF= can improve processing efficiency by reducing task switching. However, the larger the view buffer size, the more time it takes to fill. This process delays the task switching from the view task back to the request task. The delay is more apparent in interactive applications. For example, when you use the Viewtable window, the larger the view buffer, the longer it takes to display the requested observations. The view buffer must be filled before even one observation is returned to the Viewtable. Before you set a very large view buffer size, consider the following information:
  • the type of application that you are using to process the DATA step view
  • the amount of available memory

Example

For this example, the observation length is 10K. The default view buffer size, which is 32K, would result in three observations at a time to be read into the view buffer. The default view buffer size causes the execution time to be slower, because the computer must perform task switching for every three observations that are generated.
To improve performance, the OBSBUF= data set option is set to 100. This action causes 100 observations at a time to be read into the view buffer. It also reduces task switching in order to process the DATA step view with the PRINT procedure:
data testview / view=testview;
   ... more SAS statements ...
run;
proc print data=testview (obsbuf=100);
run;

See Also

Data Set Options: