
76 Handbook of SAS
®
DATA Step Programming
5.3 Using Looping to Read a List of External Files
5.3.1 Using an Iterative DO Loop to Read an External File
To read an external le, you can use the INFILE statement. Program 5.13
reads the external le, text1.txt, which is located in “C:\”.
TEXT1.TXT:
01 145
02 119
Program 5.13:
data ex5_13;
infile "C:\text1.txt";
input id $ sbp;
run;
Because there are two observations in the external le, SAS will use two
iterations in the implicit loop of the DATA step to read the data. When SAS
reaches the end-of-le marker, it stops reading.
Alternatively, you can use an explicit loop to read an external le. Inorder ...