ENDOBS= LIBNAME Statement Option

Specifies the end observation number in a user-defined range of observations to be processed.

Default: The last observation in the data set
Restrictions: Use ENDOBS= with input data sets only
Cannot be used with the OBS= system or data set option or the FIRSTOBS= system or data set option
Interactions: ENDOBS= Data Set Option
STARTOBS= LIBNAME Statement Option
STARTOBS= Data Set Option
Engine: SPD Engine only

Syntax

ENDOBS=n

Required Argument

n

is the number of the end observation.

Details

By default, the SPD Engine processes all of the observations in the entire data set unless you specify a range of observations with the STARTOBS= and ENDOBS= options. If the STARTOBS= option is used without the ENDOBS= option, the implied value of ENDOBS= is the end of the data set. When both options are used together, the value of ENDOBS= must be greater than the value of STARTOBS=.
In contrast to the default Base SAS engine option FIRSTOBS=, the STARTOBS= and ENDOBS= SPD Engine system options can be used in the LIBNAME statement.
Note: The OBS= system option and the OBS= data set option cannot be used with STARTOBS= or ENDOBS= data set or LIBNAME options.
(See SPD Engine Data Set Options for information about using the ENDOBS= data set option in WHERE processing.)

Comparisons

The ENDOBS= data set option overrides the ENDOBS= LIBNAME statement option.

Example: Using the ENDOBS= LIBNAME Statement Option

The following example shows that the STARTOBS= and ENDOBS= options subset the data before the WHERE clause executes. The example prints the four observations that were qualified by the WHERE expression (age >13 in PROC PRINT). The four observations are out of the five observations that were processed from the input data set:
libname growth spde 'SAS-library' endobs=5;
data growth.teens;
   input Name $ Sex $ Age Height Weight;
datalines;
Alfred M 14 69.0 112.5
Carol F 14 62.8 102.5
James M 13 57.3 83.0
Janet F 15 62.5 112.5
Judy F 14 64.3 90.0
Philip M 16 72.0 150.0
William M 15 66.5 112.0
;
proc print data=growth.teens;
   where age >13;
run;
ENDSOBS=
output has only 4 observations