Previous Page | Next Page

SPD Engine Data Set Options

STARTOBS= Data Set Option



Specifies the starting observation number in a user-defined range of observations to be processed.
Valid in: DATA step and PROC step
Default: the first observation in the data set
Restriction: use STARTOBS= 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 STARTOBS= with a WHERE Expression
Examples
Example 1: STARTOBS= with SPD Engine
Example 2: FIRSTOBS= with the Default Base SAS Engine

Syntax

STARTOBS=n

n

is the number of the starting 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 ENDOBS= option is used without the STARTOBS= option, the implied value of STARTOBS= is 1. When both options are used together, the value of STARTOBS= must be less than the value of ENDOBS=.

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

Note:   The FIRSTOBS= SAS data set option is not supported by the SPD Engine. The OBS= system option and the OBS= data set option cannot be used with the STARTOBS= or ENDOBS= data set or LIBNAME options.  [cautionend]


Using STARTOBS= with a WHERE Expression

When STARTOBS= is used in a WHERE expression, the STARTOBS= value represents the first observation on which to apply the WHERE expression. Compare this value to the default Base SAS engine data set option FIRSTOBS=, which specifies the starting observation number within the subset of data qualified by the WHERE expression.


Examples


Example 1: STARTOBS= with SPD Engine

A data set is created and processed by the SPD Engine with STARTOBS=5 specified. The WHERE expression is applied to the data set, beginning with observation number 5. The PRINT procedure prints six 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.1
Alice F 14 65.1 91.0
William M 15 66.5 112.0
Mike M 16 67.0 105.1
; 

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

Six Observations Printed

                  WHERE age>13 using SPD Engine 

    Obs    Name       Sex    Age    Height    Weight

     5     Judy        F      14     64.3       90.0
     6     Philip      M      16     72.0      150.0
     7     Zeke        M      14     71.1      105.1
     8     Alice       F      14     65.1       91.0
     9     William     M      15     66.5      112.0
    10     Mike        M      16     67.0      105.1

Example 2: FIRSTOBS= with the Default Base SAS Engine

The same data set is processed by the default Base SAS engine with FIRSTOBS=5 specified. PROC PRINT prints five observations, which are all of the observations qualified by the WHERE expression, starting with the fifth qualified observation. FIRSTOBS= is not supported in the SPD Engine.

libname growth v9 '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
Mike M 16 67.0 105.1
; 

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

Five Observations Printed

                                              
      WHERE age>13 using the V9 Engine               

Obs    Name       Sex    Age    Height    Weight
 6    Philip      M      16     72.0      150.0
 7    Zeke        M      14     71.1      105.1
 8    Alice       F      14     65.1       91.0
 9    William     M      15     66.5      112.0
10    Mike        M      16     67.0      105.1

Previous Page | Next Page | Top of Page