BookmarkSubscribeRSS Feed
matoma
Obsidian | Level 7

$85,000 federal student loan at annual interest rate of 7% and a payment of $500 every month. When the principal hits $50,000, the annual interest rate drops to 5%. When the principal gets down to $30,000, the annual interest rate drops to 3%. using a Do Loop how would I calculate how many years it would take to pay off the loan?

2 REPLIES 2
Astounding
PROC Star

Variations on this question have been asked quite a few times.

 

If you want help with this, you probably have to do a little more of the work.  For example, write a program that calculates the balance remaining after 1 month.  That way, it becomes apparent that you are not just looking for somebody to do your homework for you.

mkeintz
PROC Star

Here's the logic wrapped in a do loop:

 

data payments;
  principal=85000;
  do month=1 by 1 until (principal=0);
    *depending upon principal set yearly rate;
    *calculate one-month interest using principal and rate;
    *establish payment size (either $500 or current principal + interest, whichever is smaller);
    *using old principal, payment size, and calculated interest, calculate new principal
    *output a record, if wanted;
  end;
  * After the loop, from the value of MONTH, generate the number of years (it's a long time)
run;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 2 replies
  • 531 views
  • 0 likes
  • 3 in conversation