INFILE OPTIONS
Prepared by Sreeja E V(sreeja@kreara.com)
Infile has a number of options available.
FLOWOVER
FLOWOVER is the default option on INFILE statement. Here, when the INPUT statement reaches the end of non-blank characters without having filled all variables, a new line is read into the Input Buffer and INPUT attempts to fill the rest of the variables starting from column one. The next time an INPUT statement is executed, a new line is brought into the Input Buffer.
Consider the following text file containing three variables id, type and amount.
11101 A
11102 A 100
11103 B 43
11104 C
11105 C 67
The following SAS code uses the flowover option which reads the next non missing values for missing variables.
data B;
infile "External file" flowover;
input id $ type $ amount;
run;
which creates the following dataset
MISSOVER
When INPUT reads a short line, MISSOVER option on INFILE statement does not allow it to move to the next line. MISSOVER option sets all the variables without values to missing.
data B;
infile "External file" missover;
input id $ type $ amount;
run;
which creates the following dataset
TRUNCOVER
Causes the INPUT statement to read variable-length records where some records are shorter than the INPUT statement expects. Variables which are not assigned values are set to missing.
Difference between TRUNCOVER and 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.
Consider the text file below containing a character variable chr.
a
bb
ccc
dddd
eeeee
ffffff
Consider the following SAS code
data trun;
infile "External file" truncover;
input chr $3. ;
run;
When using truncover option we get the following dataset
data miss;
infile ""External file" missover;
input chr $3. ;
run;
While using missover option we get the output
1 comment:
Good Explanation!! Keep It UP
Post a Comment