<?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: Dynamic Calculations of Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Calculations-of-Variables/m-p/812080#M320384</link>
    <description>&lt;P&gt;You will need to three use arrays:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;fees: array fees Fee_YR_01-Fee_YR_04&lt;/LI&gt;
&lt;LI&gt;incs array Increase_YR_01-Increase_YR_04&lt;/LI&gt;
&lt;LI&gt;result array Result_YR_01-Result_YR_04&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;the a simple loop and the job is almost done.&lt;/P&gt;
&lt;P&gt;Have a look at the docs of the &lt;A href="https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.4/lestmtsref/p08do6szetrxe2n136ush727sbuo.htm" target="_self"&gt;array statement&lt;/A&gt;, to get the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Forgot to add a hint about improving the data structure, so here it is: the calculation would be easier if your dataset would not have data in the names of variables (YR_01 ...), but a variable holding the value of the year. With that structure the calculation would look like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  new_fee = fee * (1 + Increase / 100);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 May 2022 06:04:28 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-05-09T06:04:28Z</dc:date>
    <item>
      <title>Dynamic Calculations of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Calculations-of-Variables/m-p/812041#M320359</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have tuition fees laid out for 4 years (Variables&amp;nbsp;&lt;CODE class=" language-sas"&gt;Fee_YR_01-Fee_YR_04&lt;/CODE&gt;) starting current year (&lt;CODE class=" language-sas"&gt;Fee_YR_01&lt;/CODE&gt;). Variables&amp;nbsp;&lt;CODE class=" language-sas"&gt;Increase_YR_01-Increase_YR_04&lt;/CODE&gt;&amp;nbsp;in the sample dataset shows the proposed tuition fee increase rate (in percent) based on the previous year. I want to calculate the future tuition based on this proposed tuition increase rate (in the new variables&amp;nbsp;Fee_New_YR_02 - Fee_New_YR_04). I want a dynamic solution for this calculation.&amp;nbsp; Thank you all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My data set looks like this:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Fee_YR_01 Fee_YR_02 Fee_YR_03 Fee_YR_04 Increase_YR_01 Increase_YR_02 Increase_YR_03 Increase_YR_04;
datalines;
1000	1050	1100	1150	0	20	20	20
1000	1070	1100	1150	0	20	20	20
3000	3100	3150	3200	0	15	15	15
3000	3200	3200	3300	0	15	15	15
4000	4150	4200	4250	0	15	15	15
4000	4200	4300	4350	0	15	15	15

;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;This is the output I want:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="321"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="107"&gt;Fee_New_YR_02&lt;/TD&gt;
&lt;TD width="107"&gt;Fee_New_YR_03&lt;/TD&gt;
&lt;TD width="107"&gt;Fee_New_YR_04&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1200&lt;/TD&gt;
&lt;TD&gt;1260&lt;/TD&gt;
&lt;TD&gt;1320&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1200&lt;/TD&gt;
&lt;TD&gt;1284&lt;/TD&gt;
&lt;TD&gt;1320&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3450&lt;/TD&gt;
&lt;TD&gt;3565&lt;/TD&gt;
&lt;TD&gt;3622.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3450&lt;/TD&gt;
&lt;TD&gt;3680&lt;/TD&gt;
&lt;TD&gt;3680&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4600&lt;/TD&gt;
&lt;TD&gt;4772.5&lt;/TD&gt;
&lt;TD&gt;4830&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4600&lt;/TD&gt;
&lt;TD&gt;4830&lt;/TD&gt;
&lt;TD&gt;4945&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculations:&amp;nbsp;Fee_New_YR_02=Fee_YR_01 * 1.2 (increased by 20%)&lt;/P&gt;
&lt;P&gt;I have shown you a small set of data. But I have 150 variables for tuition fees and 150 variables for the tuition rate increase.&amp;nbsp; So I need help on how to do it dynamically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 23:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Calculations-of-Variables/m-p/812041#M320359</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2022-05-08T23:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Calculations of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Calculations-of-Variables/m-p/812080#M320384</link>
      <description>&lt;P&gt;You will need to three use arrays:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;fees: array fees Fee_YR_01-Fee_YR_04&lt;/LI&gt;
&lt;LI&gt;incs array Increase_YR_01-Increase_YR_04&lt;/LI&gt;
&lt;LI&gt;result array Result_YR_01-Result_YR_04&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;the a simple loop and the job is almost done.&lt;/P&gt;
&lt;P&gt;Have a look at the docs of the &lt;A href="https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.4/lestmtsref/p08do6szetrxe2n136ush727sbuo.htm" target="_self"&gt;array statement&lt;/A&gt;, to get the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Forgot to add a hint about improving the data structure, so here it is: the calculation would be easier if your dataset would not have data in the names of variables (YR_01 ...), but a variable holding the value of the year. With that structure the calculation would look like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  new_fee = fee * (1 + Increase / 100);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2022 06:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Calculations-of-Variables/m-p/812080#M320384</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-09T06:04:28Z</dc:date>
    </item>
  </channel>
</rss>

