<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I correctly use DO Loops for a recursive process in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460556#M117074</link>
    <description>&lt;P&gt;Solved it! I needed to add a statement in the beginning of the second DO loop to initiate the counter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 May 2018 18:53:16 GMT</pubDate>
    <dc:creator>Bumperball</dc:creator>
    <dc:date>2018-05-07T18:53:16Z</dc:date>
    <item>
      <title>How do I correctly use DO Loops for a recursive process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460094#M117027</link>
      <description>&lt;P&gt;Hi there!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create projected revenue streams for loans within a given portfolio.&amp;nbsp; PROC LOAN didn't seem like the right approach because the data set is vast and each loan can differ in structure.&amp;nbsp; I'm playing around with DO Loops thinking I can write a process where the calculations fill-in recursively.&amp;nbsp; Below is the only thing I've gotten to partially work.&amp;nbsp; It partially works because the variables are actually being created, but it's the same event for every row (see attached current output example).&amp;nbsp; The amounts are made up so the term and balance remaining won't equate in the example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;BR /&gt;        IF i &amp;gt; TRM_DUR_CT THEN i = EXIT;&lt;BR /&gt;        END;&lt;BR /&gt;        DROP i;&lt;BR /&gt;        DROP EXIT;&lt;BR /&gt;RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 15:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460094#M117027</guid>
      <dc:creator>Bumperball</dc:creator>
      <dc:date>2018-05-07T15:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correctly use DO Loops for a recursive process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460459#M117043</link>
      <description>&lt;P&gt;I realized in my first post that I wasn't initializing values for the different variables, so I have added another DO loop.&amp;nbsp; In the newest version the program correctly sets the starting values but doesn't complete the table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clarification of variable names:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Core_Pmt = the payment received that includes principal and interest&lt;/P&gt;&lt;P&gt;BOM_PRINCIPAL = Beginning of the month principal balance&lt;/P&gt;&lt;P&gt;INT_PMT = Interest payment&lt;/P&gt;&lt;P&gt;PP_PMT = Principal payment&lt;/P&gt;&lt;P&gt;EOM_PRINCIPAL = End of month principal balance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 May 2018 17:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460459#M117043</guid>
      <dc:creator>Bumperball</dc:creator>
      <dc:date>2018-05-07T17:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I correctly use DO Loops for a recursive process</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460556#M117074</link>
      <description>&lt;P&gt;Solved it! I needed to add a statement in the beginning of the second DO loop to initiate the counter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 May 2018 18:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-correctly-use-DO-Loops-for-a-recursive-process/m-p/460556#M117074</guid>
      <dc:creator>Bumperball</dc:creator>
      <dc:date>2018-05-07T18:53:16Z</dc:date>
    </item>
  </channel>
</rss>

