BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
muskagap
Fluorite | Level 6

Hello, first off - I'm a begginer, please take it into account;)

 

My problem is that I can't do simple math within loop body. I need to calculate interest capitalization after 5 years. Starting amount is 5000 USD.

 

data xyz.Capit;

amount = 5000;

i=1;

 

do while (i <= 5);

i + 1;

option1 = amount*(1,04/1);

end;


run;

 

This code can't be executed, shows errors (sth about aritmethical error). What's wrong with it?

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @muskagap  Are you after this formula and result by any chance?

 

data Capit;

amount = 5000;

i=1;
do while (i <= 5);
amount = amount*(1.04/1);
output;
i + 1;
end;

run;

proc print noobs;run;

RESULT:

amount i
5200.00 1
5408.00 2
5624.32 3
5849.29 4
6083.26 5

View solution in original post

7 REPLIES 7
Reeza
Super User

What does the log show as errors? 

Please include the log. 

 


@muskagap wrote:

Hello, first off - I'm a begginer, please take it into account;)

 

My problem is that I can't do simple math within loop body. I need to calculate interest capitalization after 5 years. Starting amount is 5000 USD.

 

data xyz.Capit;

amount = 5000;

i=1;

 

do while (i <= 5);

i + 1;

option1 = amount*(1,04/1);

end;


run;

 

This code can't be executed, shows errors (sth about aritmethical error). What's wrong with it?


 

muskagap
Fluorite | Level 6
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.
Reeza
Super User
So the errors also indicate where exactly the issue is in the full log. Because you just posted the error I can't tell which part of the code it relates to.

Assuming you're not using a French or different version of SAS, the comma issue noted may be the overall issue.

Is the error at that location in the code?
novinosrin
Tourmaline | Level 20

Hi @muskagap  Are you after this formula and result by any chance?

 

data Capit;

amount = 5000;

i=1;
do while (i <= 5);
amount = amount*(1.04/1);
output;
i + 1;
end;

run;

proc print noobs;run;

RESULT:

amount i
5200.00 1
5408.00 2
5624.32 3
5849.29 4
6083.26 5
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@muskagap you have a comma rather than a dot.

try this

data xyz.Capit;
amount = 5000;
i=1;
 
do while (i <= 5);
i + 1;
option1 = amount*(1.04/1);
end;

run;
muskagap
Fluorite | Level 6
yes, that helped:) comma!

thanks!
ballardw
Super User

You may also want to investigate the SAS Finance function. The function has options to do a number of standard financial calculations such as accrued interest, interest paid between dates, more than 30 such calculations are available from the Finance function. Plus there are about another 30 functions for financial calculations.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 895 views
  • 4 likes
  • 5 in conversation