Turn on suggestions

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

Showing results for

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 05-19-2016 12:01 PM
(1067 views)

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.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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."

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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."

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 16. Read more here about **why** you should contribute and **what is in it** for you!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.