What the others have said is right. The SAS data step is an implicit loop that will end when a particular condition is met. I think the second data step is continuously infinite because there is no set dataset
statement outside of the do loop. Hence, the data step loop does not know anything about the end of file (EOF). The point
inside the do
loop does not observe the EOF, so it cannot stop.
In data test
, a conditional trigger for ending the infinite loop was the set
statement outside of the do
loop because data sets have a finite number of entries. This means that EOF is reachable. Once the data set loop is informed that the EOF has been reached and can read no further, it will end the loop.
In addition, other triggers could also be used such as the stop;
statement or prompting the user to press some keys to end the loop.