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

need solution for below question by using do loop

 

each year an employee invests 5000 in an account determine the value of account after 3 year based on constant intrest rate of 4.5

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data _null_;
cum=0;
do n=0 to 2;
 cum=cum+1.045**n;
 
 total=5000*cum;
 year=n+1;
 put year= total= ;
end;
run;

View solution in original post

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Solution is to use SAS code.  Realy what do you expect?  You have provided nothing, where is the test data (in the form of a datastep), where is the example output.  What code have you tried etc.

art297
Opal | Level 21

There's a function for that: MORT (see: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245917.htm)

 

However, to use it, you'll have to specify whether the interest is compounded  daily, monthly or whatever.

 

Art, CEO, AnalystFinder.com

 

Ksharp
Super User
data _null_;
cum=0;
do n=0 to 2;
 cum=cum+1.045**n;
 
 total=5000*cum;
 year=n+1;
 put year= total= ;
end;
run;
Ravikumarpa4
Obsidian | Level 7

Hi

thanks for your code. i got the what i'm expecting but need one clarification on how you deceided  'cum=cum+1.045**n;'

Ksharp
Super User

It is equivalent with:

 

1

1+1.045

1+1.045+1.045**2

Yavuz
Quartz | Level 8
Hi, your question is about to "compound interest calculation" which is calculated as c=c+(1+r)^n classical formula.
C is capital, r is interest rate, n is period.
Thanks for Ksharp's solution.
Ravikumarpa4
Obsidian | Level 7

ok thanks but if want calcualte on simple interest then it will be 'cum=cum+1.045;' right?

Yavuz
Quartz | Level 8
Yes, but
If your interest rate (0.045) for one month and want to calculate simple annual interest multiply by 12
Cum=cum+(1.045)*12

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 8 replies
  • 2125 views
  • 4 likes
  • 5 in conversation