BookmarkSubscribeRSS Feed
SASUser0001
Fluorite | Level 6

hi I am looking to calculate interest for 6 months. where interest is compounded monthly. I have try to use do loop something like this but it doesnt calculate for 6 months. it only give me interest for first month. help please. 

 

do i = 1 to 6;

balance=total_balance;

interest+(((balance*rate)/100)/365)*30;

bal_1=balance+Interest;

end;

1 REPLY 1
Reeza
Super User

You probably want to add an OUTPUT statement to your loop.

 

https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n1lltvbis7ye1an1eryo4leh2mck.htm&doc...

 

do i = 1 to 6;
balance=total_balance;
interest+(((balance*rate)/100)/365)*30;
bal_1=balance+Interest;
output;
end;

If you want multiple variables with the different months you may want an array instead.

 

Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/

 


@SASUser0001 wrote:

hi I am looking to calculate interest for 6 months. where interest is compounded monthly. I have try to use do loop something like this but it doesnt calculate for 6 months. it only give me interest for first month. help please. 

 

do i = 1 to 6;

balance=total_balance;

interest+(((balance*rate)/100)/365)*30;

bal_1=balance+Interest;

end;


 

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 375 views
  • 0 likes
  • 2 in conversation