OBS= System Option

Specifies the last record to process.
Valid in: configuration file, SAS invocation, OPTIONS statement, SAS System Options window
Category: Files: SAS Files
PROC OPTIONS GROUP= SASFILES
Supports: All

Syntax

OBS=n | nK | nM | nG | nT | hexX | MIN | MAX

Syntax Description

n | nK | nM | nG | nT
specifies a number to indicate when to stop processing, with n being an integer. Using one of the letter notations results in multiplying the integer by a specific value. That is, specifying K (kilobytes) multiplies the integer by 1,024; M (megabytes) multiplies by 1,048,576; G (gigabytes) multiplies by 1,073,741,824; or T (terabytes) multiplies by 1,099,511,627,776. For example, a value of 20 specifies 20 rows or records. A value of 3m specifies 3,145,728 rows or records.
hexX
specifies a number to indicate when to stop processing as a hexadecimal value. You must specify the value beginning with a number (0–9), followed by an X. For example, the hexadecimal value F8 must be specified as 0F8x to specify the decimal equivalent of 248. The value 2dx specifies the decimal equivalent of 45.
MIN
sets the number to 0 to indicate when to stop processing.
Interaction:When OBS=0 and the NOREPLACE option is in effect, SAS can still take certain actions because it actually executes each DATA and PROC step in the program, using no rows. For example, SAS executes procedures, such as CONTENTS and DATASETS, that process libraries or SAS data sets. External files are also opened and closed. Therefore, even if you specify OBS=0, when your program writes to an external file with a PUT statement, an end-of-file mark is written, and any existing data in the file is deleted.
MAX
sets the number to indicate when to stop processing to the maximum number of rows or records, up to the largest eight-byte, signed integer, which is 263-1, or approximately 9.2 quintillion. This is the default.

Details

OBS= tells SAS when to stop processing rows or records. For example, if OBS=10 is specified, the result is 10 rows or records.
OBS= is valid for all steps during your current SAS session or until you change the setting. You can also use OBS= to control analysis of SAS data sets in PROC steps.
In WHERE processing, SAS first subsets the data, and then applies OBS= to the subset. The FEDSVR engine does not have the concept of observation numbering from the original data set. It sends back the number of rows requested, numbered chronologically, regardless of where they occur in the data set.
If SAS is processing a raw data file, OBS= specifies the last line of data to read. SAS counts a line of input data as one row, even if the raw data for several SAS data set rows is on a single line.
Operating Environment Information: The syntax that is shown here applies to the OPTIONS statement. In the command line or in a configuration file, the syntax is specific to your operating environment. For details, see the SAS documentation for your operating environment.

Comparisons

  • An OBS= specification from either a data set option or an INFILE statement option takes precedence over the OBS= system option.
  • The OBS= system option specifies an ending point for processing. The FIRSTOBS= system option specifies a starting point.

Examples

Example 1: Using OBS= to Specify When to Stop Processing Rows

This example illustrates the result of using OBS= to tell SAS when to stop processing rows. This example creates a SAS data set that contains 15 rows, executes the OPTIONS statement by specifying OBS=12, and then executes the PRINT procedure. The result is 12 rows.
libname myfiles fedsvr server="d1234.us.company.com" 
   port=2171 user=user1 pwd=pass1
   dsn=basedsn;
data myfiles.Ages;
   input Name $ Age;
   datalines;
Miguel 53
Brad 27
Willie 69
Marc 50
Sylvia 40
Gary 40
Becky 51
Alma 39
Tom 62
Kris 66
Paul 60
Randy 43
Barbara 52
Virginia 72
Arun 25
;
options obs=12;
proc print data=myfiles.Ages;
run;
PROC PRINT Output By Using OBS=
PROC PRINT Output By Using OBS=

Example 2: Using OBS= with WHERE Processing

This example illustrates the result of using OBS= along with WHERE processing. The example uses the data set that was created in Example 1, which contains 15 rows, and assumes that the SAS session has been reset to the defaults FIRSTOBS=1 and OBS=MAX. This example returns the first 10 rows that meet the WHERE criteria.
libname myfiles fedsvr server="d1234.us.company.com" 
   port=2171 user=user1 pwd=pass1
   dsn=basedsn;

options obs=10;
proc print data=myfiles.Ages;
  where Age LT 60;
run;
PROC PRINT Using a WHERE Statement and OBS=
PROC PRINT Using a WHERE Statement and OBS=