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

05-19-2016 12:01 PM

Hi

I just started to study SAS iml. it is hard for me to understand

would anybody explain.

do until(w<1e-3); /* begin do loop */

my questions: why is it used? Why "w" and "1e-3"?

y = **0.5**#(z + x/z); * Estimate square root;

my questions: Why it is written like that? But not: y = 0.

5#z or 0.5#x

I do not understand it

would you please give advice that helps me to understand? Thanks.

Accepted Solutions

Solution

05-24-2016
08:42 AM

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

Posted in reply to wenling

05-19-2016 12:50 PM

The DO UNTIL syntax is not special to SAS/IML. In SAS, a DO UNTIL loop iterates until a certain condition is met. In this case, iterate until the w variable is smaller than 0.001. The formula for y is equivalent to the more familiar DATA step syntax

y = 0.5*(z + x/z);

or

y = (z + x/z)/2;

To learn more about SAS/IML syntax, see the second and third tips in the article "Ten tips for learning the SAS/IML language."

All Replies

Solution

05-24-2016
08:42 AM

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

Posted in reply to wenling

05-19-2016 12:50 PM

The DO UNTIL syntax is not special to SAS/IML. In SAS, a DO UNTIL loop iterates until a certain condition is met. In this case, iterate until the w variable is smaller than 0.001. The formula for y is equivalent to the more familiar DATA step syntax

y = 0.5*(z + x/z);

or

y = (z + x/z)/2;

To learn more about SAS/IML syntax, see the second and third tips in the article "Ten tips for learning the SAS/IML language."

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

Posted in reply to Rick_SAS

06-03-2016 10:06 AM

do until(w<1e-3); I still do not understand why w is used, why 1e-3 is used

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

Posted in reply to wenling

06-06-2016 01:52 PM

To answer your question we would need to see the whole program. You did not provide any context or link to the source of your question.

It looks like the basis of your question is an example in the SAS/IML documentation. In the example, w measures the change between the old and new values in an iterative algorithm. The author wants to stop the algorithm when the i_th iterate is within 0.001 of the (i-1)th iterate. If you wanted greater precision, you could say

do until(w < 1e-6);

Incidentally, to better undertstand the algorithm see the article "The Babylonian method for finding square roots by hand."