turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- do loop

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-22-2017 07:37 AM

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

Accepted Solutions

Solution

02-23-2017
12:54 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-22-2017 11:07 PM

```
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;
```

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-22-2017 07:42 AM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-22-2017 09:51 AM

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

Solution

02-23-2017
12:54 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-22-2017 11:07 PM

```
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;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

02-23-2017 12:54 AM

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;'

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-23-2017 06:06 AM

It is equivalent with:

1

1+1.045

1+1.045+1.045**2

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-23-2017 01:18 AM

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.

C is capital, r is interest rate, n is period.

Thanks for Ksharp's solution.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Yavuz

02-23-2017 03:20 AM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ravikumarpa4

02-23-2017 08:00 AM

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

If your interest rate (0.045) for one month and want to calculate simple annual interest multiply by 12

Cum=cum+(1.045)*12