Desktop productivity for business analysts and programmers

Do Until Question

Reply
N/A
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);
capital+2000;
capital+capital*0.1;
year+1;
end;
run;
The expected result to me is: capiatl=7700 and year=1. The actual result is capital=. and year=7341
Why is that?
Thanks,
Ramin

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

Re: Do Until Question

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.
N/A
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
  • 132 views
  • 0 likes
  • 2 in conversation