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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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