FIRSTOBS= The FIRSTOBS option tells SAS at what line to begin reading data. This
is useful if you have a data file that contains descriptive text or header information at the
beginning, and you want to skip over these lines to begin reading the data. The following
data file, for example, has a description of the data in the first two lines:
Ice-cream sales data for the summer
Flavor Location Boxes sold
Chocolate 213 123
Vanilla 213 512
Chocolate 415 242
The following program uses the FIRSTOBS= option to tell SAS to start reading data on the third
line of the file:
DATA icecream;
INFILE ’c:\MyRawData\Sales.dat’ FIRSTOBS = 3;
INPUT Flavor $ 1-9 Location BoxesSold;
RUN;
OBS= The OBS option can be used anytime you want to read only a part of your data file.
It tells SAS to stop reading when it gets to that line in the raw data file. Note that it does not
necessarily correspond to the number of observations. If, for example, you are reading two raw
data lines for each observation, then an OBS=100 would read 100 data lines, and the resulting
SAS data set would have 50 observations. The OBS= option can be used with the FIRSTOBS=
option to read lines from the middle of the file.
For example, suppose the ice-cream sales data had a remark at the end of the file that was not part of the data.
Ice-cream sales data for the summer
Flavor Location Boxes sold
Chocolate 213 123
Vanilla 213 512
Chocolate 415 242
Data verified by Blake White
With FIRSTOBS=3 and OBS=5, SAS will start reading this file on the third data line and stop
reading after the fifth data line.
DATA icecream;
INFILE ’c:\MyRawData\Sales.dat’ FIRSTOBS = 3 OBS=5;
INPUT Flavor $ 1-9 Location BoxesSold;
RUN;
MISSOVER By default, SAS will go to the next data line to read more data if SAS has reached
the end of the data line and there are still more variables in the INPUT statement that have not
been assigned values. The MISSOVER option tells SAS that if it runs out of data, don’t go to the
next data line. Instead, assign missing values to any remaining variables. The following data file
illustrates where this option may be useful. This file contains test scores for a self-paced course.
Since not all students complete all the tests, some have more scores than others.
Nguyen 89 76 91 82
Ramos 67 72 80 76 86
Robbins 76 65 79
The following program reads the data for the five test scores, assigning missing values to tests not
completed:
DATA class102;
INFILE ’c:\MyRawData\Scores.dat’ MISSOVER;
INPUT Name $ Test1 Test2 Test3 Test4 Test5;
RUN;
TRUNCOVER You need the TRUNCOVER option when you are reading data using column
or formatted input and some data lines are shorter than others. If a variable’s field extends past the
end of the data line, then, by default, SAS will go to the next line to start reading the variable’s
value. This option tells SAS to read data for the variable until it reaches the end of the data line,
or the last column specified in the format or column range, whichever comes first. The next file
contains addresses and must be read using column or formatted input because the street names
have embedded blanks. Note that the data lines are all different lengths:
John Garcia 114 Maple Ave.
Sylvia Chung 1302 Washington Drive
Martha Newton 45 S.E. 14th St.
This program uses column input to read the address file. Because some of the addresses stop
before the end of the variable Street’s field (columns 22 through 37), you need the TRUNCOVER
option. Without the TRUNCOVER option, SAS would try to go to the next line to read the data for
Street on the first and third records.
DATA homeaddress;
INFILE ’c:\MyRawData\Address.dat’ TRUNCOVER;
INPUT Name $ 1-15 Number 16-19 Street $ 22-37;
RUN;
TRUNCOVER is similar to MISSOVER. Both will assign missing values to variables if the data
line ends before the variable’s field starts. But when the data line ends in the middle of a variable
field, TRUNCOVER will take as much as is there, whereas MISSOVER will assign the variable a
missing value.
STOPOVER
Stops the data step processing if any of the variable mentioned in input statement is missing.
TRUNCOVER
Its applicable to the last variable; if actual value available in the current record of the external file is shorter than the informat specified, it assigns that ‘Truncated’ value. If it is missing then missing value gets assigned to the variable.