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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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