BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bumperball
Fluorite | Level 6

Hi there! 

 

I am trying to create projected revenue streams for loans within a given portfolio.  PROC LOAN didn't seem like the right approach because the data set is vast and each loan can differ in structure.  I'm playing around with DO Loops thinking I can write a process where the calculations fill-in recursively.  Below is the only thing I've gotten to partially work.  It partially works because the variables are actually being created, but it's the same event for every row (see attached current output example).  The amounts are made up so the term and balance remaining won't equate in the example.

 

Any help would be greatly appreciated!

 

DATA test;
	SET schedule;
	BY MAST_CTRCT_ID;
	BOM_PRINCIPAL = EQUIPMENT_COST;
	i=MONTH;
	EXIT=TRM_DUR_CT;
	DO i=1 to EXIT;
			BOM_PRINCIPAL=EQUIPMENT_COST; 
			INT_PMT=(EQUIPMENT_COST * ((INT_RATE/100)/12));
			PP_PMT=CORE_PMT_USD_AMT - (EQUIPMENT_COST * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= EQUIPMENT_COST + (EQUIPMENT_COST * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT;
IF i > TRM_DUR_CT THEN i = EXIT;
END;
DROP i;
DROP EXIT;
RUN;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Bumperball
Fluorite | Level 6

Solved it! I needed to add a statement in the beginning of the second DO loop to initiate the counter.

 

DATA test;
	SET schedule;
	BY MAST_CTRCT_ID MONTH;
	IF FIRST.MAST_CTRCT_ID THEN DO;
			BOM_PRINCIPAL=EQUIPMENT_COST;
			INT_PMT=(EQUIPMENT_COST* ((INT_RATE/100)/12));
			PP_PMT=CORE_PMT_USD_AMT - (EQUIPMENT_COST * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= (EQUIPMENT_COST + (EQUIPMENT_COST * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT);
	END;
	ELSE DO;
			EOM_PRINCIPAL + 0;
			BOM_PRINCIPAL=EOM_PRINCIPAL; 
			INT_PMT=BOM_PRINCIPAL * ((INT_RATE/100)/12);
			PP_PMT=CORE_PMT_USD_AMT - (BOM_PRINCIPAL * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= (BOM_PRINCIPAL + (BOM_PRINCIPAL * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT);
	END;
RUN;

View solution in original post

2 REPLIES 2
Bumperball
Fluorite | Level 6

I realized in my first post that I wasn't initializing values for the different variables, so I have added another DO loop.  In the newest version the program correctly sets the starting values but doesn't complete the table. 

 

Clarification of variable names: 

 

Core_Pmt = the payment received that includes principal and interest

BOM_PRINCIPAL = Beginning of the month principal balance

INT_PMT = Interest payment

PP_PMT = Principal payment

EOM_PRINCIPAL = End of month principal balance

 

DATA test;
	SET schedule;
	BY MAST_CTRCT_ID;
	IF MONTH = 1 THEN DO;
			BOM_PRINCIPAL=EQUIPMENT_COST;
			INT_PMT=(EQUIPMENT_COST* ((INT_RATE/100)/12));
			PP_PMT=CORE_PMT_USD_AMT - (EQUIPMENT_COST * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= (EQUIPMENT_COST + (EQUIPMENT_COST * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT);
	END;
	IF MONTH ne 1 THEN DO;
			BOM_PRINCIPAL=LAG(EOM_PRINCIPAL); 
			INT_PMT=BOM_PRINCIPAL * ((INT_RATE/100)/12);
			PP_PMT=CORE_PMT_USD_AMT - (BOM_PRINCIPAL * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= (BOM_PRINCIPAL + (BOM_PRINCIPAL * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT);
	 END;
RUN;
Bumperball
Fluorite | Level 6

Solved it! I needed to add a statement in the beginning of the second DO loop to initiate the counter.

 

DATA test;
	SET schedule;
	BY MAST_CTRCT_ID MONTH;
	IF FIRST.MAST_CTRCT_ID THEN DO;
			BOM_PRINCIPAL=EQUIPMENT_COST;
			INT_PMT=(EQUIPMENT_COST* ((INT_RATE/100)/12));
			PP_PMT=CORE_PMT_USD_AMT - (EQUIPMENT_COST * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= (EQUIPMENT_COST + (EQUIPMENT_COST * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT);
	END;
	ELSE DO;
			EOM_PRINCIPAL + 0;
			BOM_PRINCIPAL=EOM_PRINCIPAL; 
			INT_PMT=BOM_PRINCIPAL * ((INT_RATE/100)/12);
			PP_PMT=CORE_PMT_USD_AMT - (BOM_PRINCIPAL * ((INT_RATE/100)/12));
			EOM_PRINCIPAL= (BOM_PRINCIPAL + (BOM_PRINCIPAL * ((INT_RATE/100)/12)) - CORE_PMT_USD_AMT);
	END;
RUN;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1229 views
  • 0 likes
  • 1 in conversation