11-27-2014 05:50 AM
do i = 9 to 11;
nextfile = "C:\sasuser\month"!!compress(put(i,2.))!!".txt";
infile temp filevar=nextfile;
if i comment the stop keyword, program going to infinite loop, what makes programe to go infinite loop, can somebody please explain?
In those files, i have data num.
My assumption is after run, it is again going to Data step and executing whole code again and again. Is it true?? If at all this is the reason, why the below code is not going infinite loop?
Can somebody please explain? Thank you very much.
11-27-2014 06:38 AM
The reason is that it reads infinitely from the file nextfile. you shall tell SAS to stop reading from each
nextfile when reaching its end. PLease check example 5 here:
11-27-2014 07:53 AM
What actually happens is this:
- start data step iteration
- start do loop
- set infile and read 1 (first) record
- iterate to next in the do loop
- when do loop has finished, go to start of data step
since you start reading every infile again in each data step iteration, you never encounter an end-of-file condition, so the data step never stops.
I suggest you read every infile with a do until (eof); and infile ..... end=eof; inside the do loop.
11-27-2014 10:14 AM
Thank you that make sense. But, when i apply same logic, why below programme stops execution after run statement, what makes end=eof makes enable?