Reading multiple records from one line - Use of double trailing @

While reading the data from external text file or mainframe member, we might come across the situation where one line in the external file is containing multiple records, For illustration suppose the data is like given below;

External File: empDetail.txt

1011 Rogger Jones 30JUL1982 1034 Nicole Davis 24JUN1982

1099 Rachel Brown 11SEP1981 1122 Michael Daniel 18NOV1988

If we observe the data we find that it had got 4 variables namely empID, emp_Fname, emp_Lname and emp_Bdate, The external file is having 2 records but 2 obeservations on each line, i.e. total of 4 observations.

We already know that input line pointer moves to the next line once it moves across input statement, So we need some holder in this case else we will end up reading only 2 records from the file.

@@ holds the pointer until each observation in that input line have been read into PDV.

So the difference between sinlge trailing @ and double trailing @@ is that 'single @' holds the pointer until Next input statement while 'double @@' holds the pointer until all the observations in the input line have been read completely

SAS code catering to the above requirement is given below,

SAS Code

Data temp;

infile "D:\empDetail.txt" ;

input empid emp_Fname:$20. emp_Lname:$20. emp_Bdate:date9. @@;

/* Note the style of input statement is just given for example;

one can use any of the input statement style */

run;

proc print data=temp;

format emp_Bdate date9.;

run;

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

and its nice to observe the output of the above code as expected.

Output: