<?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: Trying to use an array to simplify a calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721632#M223695</link>
    <description>&lt;P&gt;Repeating my earlier request to you in this thread&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Show us a portion of the data, following these instructions:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Wed, 24 Feb 2021 17:19:55 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-02-24T17:19:55Z</dc:date>
    <item>
      <title>Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717027#M221708</link>
      <description>&lt;P&gt;Hi, I am progressing through my code and have an annoyingly long calculation that is very repetitive, however, one element of it uses a calculation as a one off. I want to be able to simplify this so I am not writing it multiple times. I have included my test attempt code at the bottom to show what I was trying to do (but failing miserably)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data calc;&lt;BR /&gt;set withdrawal_data;&lt;BR /&gt;do wdwl_FC_1=((Bal_Oct20+(Bal_Oct20*Money_Out_1))+(Adjustments_1*1000000)); end;&lt;BR /&gt;do wdwl_FC_2 = ((wdwl_FC_1+(wdwl_FC_1*Money_Out_1))+(Adjustments_1*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_3 = ((wdwl_FC_2+(wdwl_FC_2*Money_Out_2))+(Adjustments_2*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_4 = ((wdwl_FC_3+(wdwl_FC_3*Money_Out_3))+(Adjustments_3*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_5 = ((wdwl_FC_4+(wdwl_FC_4*Money_Out_4))+(Adjustments_4*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_6 = ((wdwl_FC_5+(wdwl_FC_5*Money_Out_5))+(Adjustments_5*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_7 = ((wdwl_FC_6+(wdwl_FC_6*Money_Out_6))+(Adjustments_6*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_8 = ((wdwl_FC_7+(wdwl_FC_7*Money_Out_7))+(Adjustments_7*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_9 = ((wdwl_FC_8+(wdwl_FC_8*Money_Out_8))+(Adjustments_8*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_10 = ((wdwl_FC_9+(wdwl_FC_9*Money_Out_9))+(Adjustments_9*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_11 = ((wdwl_FC_10+(wdwl_FC_10*Money_Out_10))+(Adjustments_10*1000000));&lt;/P&gt;&lt;P&gt;wdwl_FC_12 = ((wdwl_FC_11+(wdwl_FC_11*Money_Out_11))+(Adjustments_11*1000000));&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;&lt;STRONG&gt;*Note this goes on for 60 iterations so I have only included 12 here and in my test&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have done the first (different) calc separately in another dataset in my test to try and get round the issue with the following code but&lt;/P&gt;&lt;P&gt;get errors in the arrays bit. Please can you help resolve this for me as driving me mad again. If there is a better way to do this instead of the arrays please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data calc;&lt;BR /&gt;set wdwl_calc;&lt;BR /&gt;wdwl_FC_202010=((Bal_Oct20+(Bal_Oct20*Money_Out_202010))+(Adjustments_202010*1000000));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data fcast;&lt;BR /&gt;set calc;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data tester;&lt;BR /&gt;set fcast;&lt;/P&gt;&lt;P&gt;array money (202010:202109) Money_Out_202010 - Money_Out_202109;&lt;BR /&gt;array wdwl (202010:202109) Adjustments_202010 - Adjustments_202109;&lt;BR /&gt;array fcwdrawal(12);&lt;BR /&gt;array wdrwal (202010:202109) Withdrawal_FC_202010 - Withdrawal_FC_202109;&lt;BR /&gt;do i = 1 to 12;&lt;BR /&gt;fcwdrawal(i) = ((Withdrawal_FC_202010+(fcwdrawal(i)*money(i)))+(wdwl(i)*1000000));&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 10:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717027#M221708</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-05T10:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717036#M221714</link>
      <description>&lt;P&gt;From your code, I take it that you suffer from a bad dataset layout (data (dates) in structure (column names)).&lt;/P&gt;
&lt;P&gt;You should first transpose that to a long layout, and then you do a running calculation with retained variables.&lt;/P&gt;
&lt;P&gt;For help with the transposition, supply a short example of your dataset, ideally as a data step with datalines.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 10:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717036#M221714</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-05T10:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717064#M221725</link>
      <description>Your array dimensions are off.  &lt;BR /&gt;&lt;BR /&gt;(202010:202109)&lt;BR /&gt;&lt;BR /&gt;This includes all integers in the range, such as 202013, 202014, all the way through 202099.</description>
      <pubDate>Fri, 05 Feb 2021 13:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717064#M221725</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-02-05T13:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717066#M221726</link>
      <description>&lt;P&gt;So as the data has each element with a date and month in it ie 202010 for October 20 what would I need to change the dimensions to in order to get it to pull these through.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 13:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717066#M221726</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-05T13:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717074#M221730</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/367385"&gt;@djk200399&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So as the data has each element with a date and month in it ie 202010 for October 20 what would I need to change the dimensions to in order to get it to pull these through.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us a portion of the data, following these instructions:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 14:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717074#M221730</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-05T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717081#M221733</link>
      <description>&lt;P&gt;Fix the index into the array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tester;
  set fcast;
  array money Money_Out_202010 - Money_Out_202012 Money_Out_202101-Money_Out_202109;
  array wdwl Adjustments_202010 - Adjustments_202012 Adjustments_202101 - Adjustments_202109;
  array fcwdrawal [12];
  array wdrwal  Withdrawal_FC_202010 - Withdrawal_FC_202012 Withdrawal_FC_202101 - Withdrawal_FC_202109;
  do i = 1 to 12;
    fcwdrawal[i] = ((Withdrawal_FC_202010+(fcwdrawal[i]*money[i]))+(wdwl[i]*1000000));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Feb 2021 14:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717081#M221733</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-05T14:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717115#M221742</link>
      <description>&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;So are you suggesting if I have an array with the multiple years noted next to it, as you have done here it should fix the issue?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I will give this a go on the code later on. Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 16:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717115#M221742</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-05T16:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717118#M221743</link>
      <description>&lt;P&gt;Hi Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your suggestion but get an error saying array subscript out of range at line 30 column 20. I will try and sort the sharing of a dataset on Monday that way it might be easier to see what I am doing wrong !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 17:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/717118#M221743</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-05T17:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721629#M223693</link>
      <description>&lt;P&gt;I have transposed my datasets (which I know do all the time when reading them in from excel) to improve things but need to work out how to do this via an array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 data sets that look like this&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Dataset A&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;brand&lt;/TD&gt;&lt;TD&gt;product&lt;/TD&gt;&lt;TD&gt;period&lt;/TD&gt;&lt;TD&gt;acc&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Regular&lt;/TD&gt;&lt;TD&gt;202010&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Fixed&lt;/TD&gt;&lt;TD&gt;202010&lt;/TD&gt;&lt;TD&gt;350&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Regular&lt;/TD&gt;&lt;TD&gt;202010&lt;/TD&gt;&lt;TD&gt;250&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Fixed&lt;/TD&gt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B&lt;/TD&gt;&lt;TD&gt;Fixed&lt;/TD&gt;&lt;TD&gt;202102&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;Regular&lt;/TD&gt;&lt;TD&gt;202102&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the 2 datasets to undertake an ongoing calculation&lt;/P&gt;&lt;P&gt;The first dataset is one that was created last month with forecast numbers going forward from an actual position in 202010&lt;/P&gt;&lt;P&gt;The second is the new calculation that needs to take place on this dataset but using the prior month result&lt;/P&gt;&lt;P&gt;So in the case of no1 the first calc should be acc for 202010 from dataset A plus int for 202011 from dataset B. The second calc should use the outcome of the first calc as it's starting point and then add int for 202012 from dataset B and so on until the end.&lt;/P&gt;&lt;P&gt;How do I use the result of each calc for the next calculation simply and efficiently ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I should see here results wise using no1 as an example is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;calc&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202011&lt;/TD&gt;&lt;TD&gt;310&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202012&lt;/TD&gt;&lt;TD&gt;330&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202101&lt;/TD&gt;&lt;TD&gt;332&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;202102&lt;/TD&gt;&lt;TD&gt;344&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this makes sense and would an array work to do this or am I over complicating things??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance of your help again&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721629#M223693</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-24T17:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721632#M223695</link>
      <description>&lt;P&gt;Repeating my earlier request to you in this thread&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Show us a portion of the data, following these instructions:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721632#M223695</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-24T17:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721800#M223762</link>
      <description>&lt;P&gt;I have tried running the said macro but it does not work in my SAS given some of the internal restrictions. Instead I have attached the two datasets (simplified versions) as csv's for a quick upload.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for these I need a calculation of acc from accrual dataset at 202010 + the value of calc from the all1 dataset for 202011 merged by the no1 field and then the next calculation will be the last calculation we did + value of calc from the all dataset for 202012 merged by the no1 field and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help on this.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 10:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721800#M223762</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-25T10:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721814#M223764</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=ds_a (where=(period='01oct2020'd))
  out=ds_a_
;
by brand product;
run;

proc sort
  data=ds_b (where=(period ge '01nov2020'd))
  out=ds_b_
;
by brand product_period;
run;

data want;
merge
  ds_a_
  ds_b_
;
by brand product;
if first.product
then calc = acc;
calc + int;
keep brand product calc;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, for lack of&amp;nbsp;&lt;EM&gt;usable&lt;/EM&gt; data.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 11:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721814#M223764</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-25T11:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721817#M223765</link>
      <description>&lt;P&gt;There is no variable int in any of your CSV's.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;PLEASE POST USABLE DATA.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(which fits your descriptions, or adapt the descriptions to the data)&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 11:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721817#M223765</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-25T11:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use an array to simplify a calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721859#M223783</link>
      <description>&lt;P&gt;Apologies for not including the correct data, I managed to do a similar solution to yours Kurt so apologies for the failure on my part&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 13:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-an-array-to-simplify-a-calculation/m-p/721859#M223783</guid>
      <dc:creator>djk200399</dc:creator>
      <dc:date>2021-02-25T13:45:06Z</dc:date>
    </item>
  </channel>
</rss>

