Previous Page | Next Page

SPD Engine Data Set Options

ENDOBS= Data Set Option



Specifies the end observation number in a user-defined range of observations to be processed.
Valid in: DATA step and PROC step
Used with: STARTOBS= data set option
Default: the last observation in the data set
Restriction: use ENDOBS= with input data sets only
Restriction: cannot be used with OBS= system and data set option or FIRSTOBS= system and data set option

Syntax
Details
Using ENDOBS= in a WHERE Expression
Examples
Example 1: ENDOBS= with SPD Engine
Example 2: OBS= with SPD Engine

Syntax

ENDOBS=n

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= or 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=.

The ENDOBS= data set option in the SPD Engine works the same way as the OBS= data set option in the default Base SAS engine, except when it is specified in a WHERE expression.


Using ENDOBS= in a WHERE Expression

When ENDOBS= is used in a WHERE expression, the ENDOBS= value represents the last observation to process, rather than the number of observations to return. The following examples show the difference.

Note:    The OBS= system option and the OBS= data set option cannot be used with STARTOBS= or ENDOBS= data set or LIBNAME options.  [cautionend]


Examples


Example 1: ENDOBS= with SPD Engine

A data set is created and processed by the SPD Engine with ENDOBS=5 specified. The WHERE expression is applied to the data set ending with observation number 5. The PRINT procedure prints four observations, which are the observations qualified by the WHERE expression.

libname growth spde 'c:\temp';

data growth.teens;
   input Name $ Sex $ Age Height Weight;
   list;

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
Zeke M 14 71.1 105.0
Alice F 14 65.1 91.0
William M 15 66.5 112.0
; 

proc print data=growth.teens (endobs=5);
   where age >13;
   title 'WHERE age>13 using SPD Engine';
run;

The output is shown:

Four Observations Printed

                 WHERE age>13 using SPD Engine

     Obs     Name     Sex    Age    Height    Weight

      1     Alfred     M      14     69.0      112.5
      2     Carol      F      14     62.8      102.5
      4     Janet      F      15     62.5      112.5
      5     Judy       F      14     64.3       90.0

Example 2: OBS= with SPD Engine

The same data set is processed with OBS=5 specified. PROC PRINT prints five observations, which are all of the observations qualified by the WHERE expression, ending with the fifth qualified observation.

libname growth spde 'c:\temp';

data growth.teens;
   input Name $ Sex $ Age Height Weight;
   list;

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
Zeke M 14 71.1 105.1
Alice F 14 65.1 91.0
William M 15 66.5 112.0
; 

proc print data=growth.teens (obs=5);
   where age >13;
   title 'WHERE age>13 using V9';
run;

Five Observations Printed

                 WHERE age>13 using V9

     Obs     Name     Sex    Age    Height    Weight

      1     Alfred     M      14     69.0      112.5
      2     Carol      F      14     62.8      102.5
      4     Janet      F      15     62.5      112.5
      5     Judy       F      14     64.3       90.0
      6     Philip     M      16     72.0      150.0

Previous Page | Next Page | Top of Page