Can't find my loop!!

Accepted Solution Solved
Reply
Contributor
Posts: 73
Accepted Solution

Can't find my loop!!

I have created a data step that:

  • Reads through an array to build a file name
  • Verifies that each file exists
  • Performs an input on each found file until end of file

On days we have trouble with our systems, I'm assuming the end of file indicator does not get set and throws my data step into a loop. I've attached the output of a test that I've run with the assuming "incomplete" files causing me trouble, with a put statement displaying each file name through a 10 step loop. I don't understand how I am getting the attached output if the second and third DO loops are obviously getting set complete to branch back to the first DO loop. I'm obviously missing something.

Any time spent on this is MUCH appreciated!

~Jeff

Newbie @ SAS

Attachment

Accepted Solutions
Solution
‎05-15-2012 01:47 PM
Super User
Posts: 5,085

Re: Can't find my loop!!

Jeff,

The problem is with the DELETE statement.  When it executes, it doesn't just leave the interior DO loop.  It exits all the way to the top of the DATA step.  Then the outer loop (DO I=1 TO 10) begins again with I=1.

Change the interior logic so there is no DELETE, something like:

 

IF MEANRESP >= 0 AND NBRTRANS >= 0 THEN OUTPUT;

I expect that would do it.

Good luck.

View solution in original post


All Replies
Solution
‎05-15-2012 01:47 PM
Super User
Posts: 5,085

Re: Can't find my loop!!

Jeff,

The problem is with the DELETE statement.  When it executes, it doesn't just leave the interior DO loop.  It exits all the way to the top of the DATA step.  Then the outer loop (DO I=1 TO 10) begins again with I=1.

Change the interior logic so there is no DELETE, something like:

 

IF MEANRESP >= 0 AND NBRTRANS >= 0 THEN OUTPUT;

I expect that would do it.

Good luck.

Contributor
Posts: 73

Re: Can't find my loop!!

Well played sir!

I don't think I ever would have figured that out and I was researching this for a while. I haven't run across any lessons/articles relating to SAS statements causing an abrupt exit from a DO loop. Now it makes me wonder what other statements cause this as well. At least I know what to search on now.

Thank you Astounding!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 215 views
  • 0 likes
  • 2 in conversation