LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 23 May 2006 13:55:51 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: Very Simple: Do Until
Comments: To: franz_cl2003@YAHOO.FR
In-Reply-To:  <20060523134142.81856.qmail@web25603.mail.ukl.yahoo.com>
Content-Type: text/plain; format=flowed

Franz simple math:

In the first data step you are decreaseing Stock by one unit and therefore if you keep decreaseing the value for stock by one unit it will eventually reach 0.

In the second data step you are decreasing the value of stock by 2. And since stock starts with a value of 5 no matter how many times you substract 2 units from the value of stock it will never be equal to 0 (which is what you are testing for in the do until). If you switcj the initial value of Stock to say 6, it will stop correctly or if you change your until condition to say

do until( stock <= 0 ) ;

Toby Dunn

From: Franz <franz_cl2003@YAHOO.FR> Reply-To: Franz <franz_cl2003@YAHOO.FR> To: SAS-L@LISTSERV.UGA.EDU Subject: Very Simple: Do Until Date: Tue, 23 May 2006 06:41:41 -0700

Dear all,

The first program runs very well. But why not the second one?

First Prog.

data test; stock =2; nbr_ = 0; do until(stock=0); stock = stock -1; nbr_ = nbr_ +1; output; end; run;

Second Prog.

data test; stock =5; nbr_ = 0; do until(stock=0); stock = stock-2; nbr_ = nbr_ +1; output; end; run;

Thanks & regards, Franz.

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com


Back to: Top of message | Previous page | Main SAS-L page