Return to Archive

SAS Tip of the Month
February 2004

There are a few of ways in SAS that limit the number of observations being processed in a datastep or procedure. Two of the more least known are FIRSTOBS= and OBS=, both used as options and are defined as follows:

FIRSTOBS= the number of the first observation to be processed and is a positive integer that is less than or equal to the number of observations in the data set.

OBS= the number of the last observation to be processed and is a positive integer that is less than or equal to the number of observations in the data set or zero. Additionally OBS= can have the value MAX that represents the total number of observations in the dataset.

The following is an example of their usage, selecting observations 10 though to 30 from the dataset SUBANALYSIS for processing in the PRINT procedure:

   title1 "Listing of Obs. 10 to 30 of the SUBANALYSIS "
          "Dataset for Testing Purposes";
   proc print data=subanalysis (FIRSTOBS=10 OBS=30);
   run;

As the example implies these options are best used for Development, Testing or Quality Control purposes so as to reduce time for processing – more often than not all data is processed for production reporting purposes.

________________________________
Updated February 4, 2004