FIRSTOBS= Data Set Option

Specifies the first row in a data source that SAS processes.

Valid in: DATA and PROC steps
Category: Observation Control
Restriction: Valid for input (Read) processing only.
Supports: All

Syntax

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

Syntax Description

n | nK | nM | nG

specifies the number of the first row 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 row, and a value of 3k specifies 3,072.

hexX

specifies the number of the first row 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 row as the first row to process.

MIN

sets the number of the first row to process to 1. This is the default.

MAX

sets the number of the first row to process to the maximum number of rows in the data set, up to the largest eight-byte, signed integer, which is 263-1, or approximately 9.2 quintillion rows.

Details

The FIRSTOBS= data set option affects a single, existing file. 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.

Comparisons

  • The FIRSTOBS= data set option overrides the FIRSTOBS= system option for the individual data set.
  • The FIRSTOBS= data set option specifies a starting point for processing. The OBS= data set option specifies an ending point.
  • When external files are read, the FIRSTOBS= option in the INFILE statement specifies which record to read first.

Examples

Example 1: Using FIRSTOBS= in PROC PRINT

This PROC step prints the data set Study beginning with row 20:
data myfiles.study;
   input char $ @@;
   datalines;
aa bb cc dd ee ff gg
hh ii jj kk ll mm nn
oo pp qq rr ss tt uu
vv ww xx yy zz
;
proc print data=myfiles.study (firstobs=20);
run;

Example 2: Using FIRSTOBS= in the SET Statement

This SET statement uses both FIRSTOBS= and OBS= to read only rows 5 through 10 from the data set Study. Data set New contains six rows.
data new;
  set study(firstobs=5 obs=10);
run;
proc print data=new;
 run;