@Look at the INPUT statement. You are using both @ to denote the position of where to start reading and a trailing @.
@the trailing @ keeps the pointer at the line for that data step iteration. At the next data step iteration it moves on. Check the behaviour by running the code with and without the trailing @.
input @1 Var1 $ @8 @Var2 $ @; <- reads var1 starting from position1, var2 from position 8 and holds the line.
input @1 Var3 $ @8@ Var4 $ @; <- reads var3 starting from position1, var4 from position 8 and holds the line. The run allows it to move to a new line.
@mohitraj4u wrote:
Given the text file COLORS.TXT:
----+----1----+----2----+----
RED ORANGE YELLOW GREEN
BLUE INDIGO PURPLE VIOLET
CYAN WHITE FUCSIA BLACK
GRAY BROWN PINK MAGENTA
The following SAS program is submitted:
data WORK.COLORS;
infile 'COLORS.TXT';
@ input @1 Var1 $ @8 Var2 $ @;
@ input @1 Var3 $ @8 Var4 $ @; run;
What will the data set WORK.COLORS contain?
Answer:
Var1 Var2 Var3 Var4 ------ ------ ------ ------ RED ORANGE RED ORANGE BLUE INDIGO BLUE INDIGO CYAN WHITE CYAN WHITE GRAY BROWN GRAY BROWN
... View more