@ChiragJPatel
It's rather rare that you want to address multiple source rows in a single iteration of the data step. The reason is: If there is any variation in the number of source rows per "block" then everything gets messed-up.
If dealing with a case like yours you normally try to implement some logic which determines what source of row you're dealing with and then fork to the logic required to read this type of data. That's what below code does.
data read;
infile datalines truncover dlm=' ';
retain name;
/* read source row into input buffer. @ to keep pointer on this row */
input @;
/* if first character in input buffer is not a digit then read as name */
if anydigit(substrn(_infile_,1,1))=0 then
input name $8.;
/* else: read numbers. Only write to output if we're reading numbers */
else
do;
input var1 var2 var3;
output;
end;
datalines;
File A
10 20 30
40 50 60
70 80 90
File B
10 20 30
40 50 60
70 80 90
File C
10 20 30
40 50 60
70 80 90
File D
10 20 30
40 50 60
70 80 90
File E
10 20 30
40 50 60
70 80 90
;
Here how the code would need to look like if reading from multiple lines.
data read;
infile datalines truncover dlm=' ' n=4;
retain name;
input
#1 name $8.
#2 var1 var2 var3 @;
output;
input #3 var1-var3 @;
output;
input #4 var1-var3;
output;
datalines;
File A
10 20 30
40 50 60
70 80 90
File B
10 20 30
40 50 60
70 80 90
File C
10 20 30
40 50 60
70 80 90
File D
10 20 30
40 50 60
70 80 90
File E
10 20 30
40 50 60
70 80 90
;
... View more