SAS List input - Reading External text Files

Reading External files with list input is very simple among other types.

    • Here all the variables should have been separated by at least one blank.

    • SAS reads all the variables seqentially according to that mentioned in INPUT statement in accordance with provided data types.

      • For example lets take the extract of the external file given below;

External File: empDetail.txt

1011 Rogger Jones 20JUL78 3400

1012 Nicole Davis 17JAN83 3000

1013 Rachel Brown 30APR81 3600

1014 Michael Daniel 11SEP79 3800

This is very easy to achieve using simple SAS code below.

SAS Code:

data temp;

infile "D:\empDetail.txt";

input empID emp_Fname $ emp_Lname $ emp_Bdate $ emp_basic_sal;

run;

proc print data=temp;

run;

*note that above code has been compiles on SAS 9.1 platform

And following is the output which all says by itself.

Output: