Cornell University Cornell University CISER

CISER Computing

Reading Variable Length Files with SAS

Q.  My raw data are not in a rectangular file. Some lines are longer than others. Can I still use SAS to read my data?

A.  To read a raw data file with variable length records, use the INFILE options MISSOVER and PAD along with LRECL (lrecl is the maximum record length). Below is an example.

data temp;
   infile 'a:\varlen.txt' lrecl=10 missover pad;
   input var1 1-2  var2 4-10;
run;

/* Use the following DATA step to determine the maximum record length for the input file. In INFILE statement put an arbitrary high number for LRECL. When you submit these statements SAS log will include the true maximum record length for the file */

data _null_;
   infile 'a:\varlen.txt' lrecl=500000 ;
   input;
run;