0
votes

I am studying SAS on my own. I have no one to refer to so I just wanted to check if my code is correct.

In a fixed term deposit of 25 years calculate the total amount at the end of term with initial amount of $5,00,000 and annual interest rate of 7 % */ 1) Compounded Annually 2) Compounded Monthly.Show the amount at monthly level

My Code:
data deposit;
amount = 500000;
rate = 0.07;
do year = 1 to 25;
amount + earned;
earned + (amount*0.07);
principal = amount + earned;
output;
end;
run;

For the second question compounded monthly

data deposit1;
rate = 0.006;
amount1 = 500000;
do year = 1 to 25;
do month = 1 to 12;
earned1 + (earned1 + amount1)*0.006;
amount1 + earned1;
output;
end;
end;
run;

Pasting the Screenshots of Solution 1 and Solution 2 Problem 1 Result Problem 2 Result

I am confused because when I compound annually and monthly both have different results at the end of a particular year.

Please suggest if anything is wrong in my code. Thank you for your time and attention.

1
Why did you change the interest rate from 7% in the annual calculations to 6% in the monthly calculations?Tom

1 Answers

1
votes

It looks like you are double-counting your earned1 variable in the monthly compounding code.

earned1 + (earned1 + amount1)*0.006;
amount1 + earned1;

Should be:

earned1 = amount1*0.07**(1/12);
amount1 + earned1;

Note also you will not want to round the interest rate.