FIRSTOBS= Data Set Option

Specifies the first observation that SAS processes in a SAS data set.
Valid in: DATA step and PROC steps
Category: Observation Control
Restrictions: Valid for input (read) processing only.

Cannot use with PROC SQL views.

Syntax

FIRSTOBS= n| nK | nM | nG | hexX | MIN | MAX

Syntax Description

n | nK | nM | nG
specifies the number of the first observation to process in multiples of 1 (bytes); 1,024 (kilobytes); 1,048,576 (megabytes); or 1,073,741,824 (gigabytes). For example, a value of 8 specifies the 8th observation, and a value of 3k specifies 3,072.
hexX
specifies the number of the first observation to process as a hexadecimal value. You must specify the value beginning with a number (0-9), followed by an X. For example, the value 2dx sets the 45th observation as the first observation to process.
MIN
sets the number of the first observation to process to 1. This is the default.
MAX
sets the number of the first observation to process to the maximum number of observations in the data set, up to the largest eight-byte, signed integer, which is 263-1, or approximately 9.2 quintillion observations.

Details

The FIRSTOBS= data set option affects a single, existing SAS data set. Use the FIRSTOBS= system option to affect all steps for the duration of your current SAS session.
FIRSTOBS= is valid for input (read) processing only. Specifying FIRSTOBS= is not valid for output or update processing.
You can apply FIRSTOBS= processing to WHERE processing. For more information, see Processing a Segment of Data That Is Conditionally Selected in SAS Language Reference: Concepts.

Comparisons

  • The FIRSTOBS= data set option overrides the FIRSTOBS= system option for the individual data set.
  • While the FIRSTOBS= data set option specifies a starting point for processing, the OBS= data set option specifies an ending point. The two options are often used together to define a range of observations to be processed.
  • When external files are read, the FIRSTOBS= option in the INFILE statement specifies which record to read first.

Example: Example

This PROC step prints the data set STUDY beginning with observation 20:
 
proc print data=study(firstobs=20);
run;
This SET statement uses both FIRSTOBS= and OBS= to read-only observations 5 through 10 from the data set STUDY. Data set NEW contains six observations.
data new;
  set study(firstobs=5 obs=10);
run;
proc print data=new;
 run;

See Also

Data Set Options:
Statements:
INFILE Statement in SAS Statements: Reference
WHERE Statement in SAS Statements: Reference
System Options:
FIRSTOBS= System Option in SAS System Options: Reference