Desktop productivity for business analysts and programmers

Do Until Question

Not applicable
Posts: 0

Do Until Question

Hi there.
It's said in SAS texts that statements in the Do Until execute at least once. Here is an example:
data invest;
capital = 5000;
do until (capital le 5000);
The expected result to me is: capiatl=7700 and year=1. The actual result is capital=. and year=7341
Why is that?

Message was edited by: RaminR Message was edited by: RaminR
Super Contributor
Super Contributor
Posts: 3,176

Re: Do Until Question

Posted in reply to deleted_user
The DO UNTIL condition is evaluated at the end of the loop (but only after at least one pass is completed):

Add the command below to your DO loop (use PUT if not yet at SAS 9) - it will help reveal the events of your DO loop:

putlog _all_;

Also I ran you code and the SASLOG generated the following message:

capital=1.630347E308 year=7339 _ERROR_=0 _N_=1
capital=1.793382E308 year=7340 _ERROR_=0 _N_=1
NOTE: A number has become too large at line 5 column 16.
The number is >1.80E+308 or <-1.80E+308.
capital=. year=7341 _ERROR_=1 _N_=1
capital=. year=7341 _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of
the operations have been set to missing values.
Each place is given by: (Number of times) at (Line)Smiley SadColumn).
1 at 5:16
NOTE: The data set WORK.INVEST has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):

Scott Barry
SBBWorks, Inc.
Not applicable
Posts: 0

Re: Do Until Question

Thanks Scott. Yes I see I've made a terrible mistake. Thanks for your time on this.
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation