BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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):(Column).
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.
deleted_user
Not applicable
Thanks Scott. Yes I see I've made a terrible mistake. Thanks for your time on this.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1318 views
  • 0 likes
  • 2 in conversation