turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-03-2013 12:43 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-03-2013 01:24 PM

With any DO UNTIL loop, it is possible that it never ends because the UNTIL condition never becomes true. In your case, this condition might never become true: (n < 0.001)

One way to guard against it is to allow two ways for the loop to end:

do k=1 to 100000 until (n < 0.001);

If the loop iterates 100,000 times, it will end regardless of the value of n. Your subsequent statements might have to allow for the possibility that n > 0.001. The loop will end before 100,000 iterations if the UNTIL condition becomes true.

Good luck.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-03-2013 09:17 PM

Thank you so much.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-03-2013 01:33 PM

Welcome to SAS! To break the infinite DO UNTIL loop, I often include a maximum number of iterations, like this:

maxIter = 50;

iter = 0;

do until(n<0.001 | iter>=maxIter);

/* computations */

n = sqrt(direc[##]);

iter = iter + 1;

end;

If I might offer another suggestion, your computation is looping over the I variable 50,000 times and updating elements of vectors. It might be possible for you to eliminate that loop. For ideas, see

http://blogs.sas.com/content/iml/2013/05/15/vectorize-computations/

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-03-2013 09:18 PM

Thank you so much.