<?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 Creating a number of variables after reading a value in the Observation(dynamically) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535553#M147083</link>
    <description>&lt;P&gt;The data I have is like following with thousands of rows:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;APP&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;amount&lt;/TD&gt;&lt;TD&gt;rate1&lt;/TD&gt;&lt;TD&gt;rate2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;84&lt;/TD&gt;&lt;TD&gt;10000&lt;/TD&gt;&lt;TD&gt;0.09&lt;/TD&gt;&lt;TD&gt;0.095&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;TD&gt;0.1&lt;/TD&gt;&lt;TD&gt;0.12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;0.13&lt;/TD&gt;&lt;TD&gt;0.135&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;TD&gt;0.12&lt;/TD&gt;&lt;TD&gt;0.124&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each row I need to calculate something like:&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;payment1=mort(amount, ., rate1/12,n);&lt;BR /&gt;int1_inc_yr1 = CUMIPMT (rate1/12, n, amount, 1, 12, 0);&lt;BR /&gt;bal1_endyr1 = AMOUNT - CUMPRINC (rate1/12, n, amount, 1, 12, 0);&lt;BR /&gt;int1_inc_yr2 = CUMIPMT (rate1/12, n, amount, 13, 24, 0);&lt;BR /&gt;bal1_endyr2 = bal_endyr1- CUMPRINC (rate1/12, n, amount, 13, 24, 0);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;...&amp;lt;For all the years in term, for 120 term, this will go for 12 years, this is not fixed as each application will have a different term&amp;gt;&lt;/P&gt;&lt;P&gt;...&amp;lt;This then I need to repeat for other Interest Rates as well, in data I have given 2 rates, it may go upto 5 rates&amp;gt;&lt;BR /&gt;the output I need is:&lt;/P&gt;&lt;P&gt;For each row(application), all the 'Interest Accumulated' and 'End of Year Principal Balance' in each year during it's term...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried PROC LOAN to do this but supplying each row one at a time takes too long.&lt;/P&gt;&lt;P&gt;Any idea on how to do this efficiently in DATA step or any other method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(P.S. - I then have to use this output for further calculations in PROC IML. Each row will interact with other matrces there.)&lt;/P&gt;</description>
    <pubDate>Thu, 14 Feb 2019 11:42:26 GMT</pubDate>
    <dc:creator>thepushkarsingh</dc:creator>
    <dc:date>2019-02-14T11:42:26Z</dc:date>
    <item>
      <title>Creating a number of variables after reading a value in the Observation(dynamically)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535553#M147083</link>
      <description>&lt;P&gt;The data I have is like following with thousands of rows:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;APP&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;amount&lt;/TD&gt;&lt;TD&gt;rate1&lt;/TD&gt;&lt;TD&gt;rate2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;84&lt;/TD&gt;&lt;TD&gt;10000&lt;/TD&gt;&lt;TD&gt;0.09&lt;/TD&gt;&lt;TD&gt;0.095&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;TD&gt;0.1&lt;/TD&gt;&lt;TD&gt;0.12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;0.13&lt;/TD&gt;&lt;TD&gt;0.135&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;TD&gt;0.12&lt;/TD&gt;&lt;TD&gt;0.124&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each row I need to calculate something like:&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;payment1=mort(amount, ., rate1/12,n);&lt;BR /&gt;int1_inc_yr1 = CUMIPMT (rate1/12, n, amount, 1, 12, 0);&lt;BR /&gt;bal1_endyr1 = AMOUNT - CUMPRINC (rate1/12, n, amount, 1, 12, 0);&lt;BR /&gt;int1_inc_yr2 = CUMIPMT (rate1/12, n, amount, 13, 24, 0);&lt;BR /&gt;bal1_endyr2 = bal_endyr1- CUMPRINC (rate1/12, n, amount, 13, 24, 0);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;...&amp;lt;For all the years in term, for 120 term, this will go for 12 years, this is not fixed as each application will have a different term&amp;gt;&lt;/P&gt;&lt;P&gt;...&amp;lt;This then I need to repeat for other Interest Rates as well, in data I have given 2 rates, it may go upto 5 rates&amp;gt;&lt;BR /&gt;the output I need is:&lt;/P&gt;&lt;P&gt;For each row(application), all the 'Interest Accumulated' and 'End of Year Principal Balance' in each year during it's term...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried PROC LOAN to do this but supplying each row one at a time takes too long.&lt;/P&gt;&lt;P&gt;Any idea on how to do this efficiently in DATA step or any other method?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(P.S. - I then have to use this output for further calculations in PROC IML. Each row will interact with other matrces there.)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 11:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535553#M147083</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2019-02-14T11:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a number of variables after reading a value in the Observation(dynamically)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535615#M147105</link>
      <description>Use two arrrays.</description>
      <pubDate>Thu, 14 Feb 2019 15:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535615#M147105</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-14T15:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a number of variables after reading a value in the Observation(dynamically)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535651#M147115</link>
      <description>&lt;P&gt;I tried like following with desired results but there's lots of notes and in the end a warning because of operations on missing values, (since I am selecting max term):&lt;/P&gt;&lt;P&gt;%macro _stupid_;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select max(n) into :max_term from one;&lt;/P&gt;&lt;P&gt;quit;&lt;BR /&gt;data two;&lt;BR /&gt;set one ;&lt;/P&gt;&lt;P&gt;%do j=1 %to 2;&lt;BR /&gt;payment&amp;amp;j.=mort(amount, ., rate&amp;amp;j./12,n);&lt;BR /&gt;%do i=1 %to &amp;amp;max_term.;&lt;BR /&gt;int_inc&amp;amp;j._yr_&amp;amp;i. = CUMIPMT (rate&amp;amp;j./12, n, amount, 1, 12, 0);&lt;BR /&gt;bal_begin&amp;amp;j._yr_&amp;amp;i. = amount;&lt;BR /&gt;%if &amp;amp;i.&amp;gt;1 %then %do;&lt;BR /&gt;int_inc&amp;amp;j._yr_&amp;amp;i. = CUMIPMT (rate&amp;amp;j./12, n, amount, %eval(%eval(&amp;amp;i.-1)*12+1), %eval(&amp;amp;i.*12), 0);&lt;BR /&gt;bal_begin&amp;amp;j._yr_&amp;amp;i. = bal_begin&amp;amp;j._yr_%eval(&amp;amp;i.-1)- CUMPRINC (rate&amp;amp;j./12, n, amount, %eval(%eval(&amp;amp;i.-2)*12+1), %eval(%eval(&amp;amp;i.-1)*12), 0);&lt;BR /&gt;%end;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%_stupid_&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 17:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535651#M147115</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2019-02-14T17:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a number of variables after reading a value in the Observation(dynamically)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535654#M147117</link>
      <description>Don't use macros, use arrays. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;</description>
      <pubDate>Thu, 14 Feb 2019 17:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535654#M147117</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-14T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a number of variables after reading a value in the Observation(dynamically)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535819#M147174</link>
      <description>Thank you very much. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 15 Feb 2019 09:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-number-of-variables-after-reading-a-value-in-the/m-p/535819#M147174</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2019-02-15T09:44:17Z</dc:date>
    </item>
  </channel>
</rss>

