<?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: ARRAY: Avg of Last X Number of Months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297068#M62342</link>
    <description>&lt;P&gt;If you have any control of your data structure change it to a long format. Keeping data in a wide format isn't efficient for so many reasons. This becomes trivial if you switch to a long format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you can use some calculations to determine what your field values should be based on your current date and use VVALUE/VVALUEX to retrieve the correct values and average them.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Sep 2016 20:58:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-09-07T20:58:31Z</dc:date>
    <item>
      <title>ARRAY: Avg of Last X Number of Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297063#M62339</link>
      <description>&lt;P&gt;Hey Guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to figure out how to do a mean of the last 6 months of balances. I have a table that I keep on appending to every new end of month. E.g. Bal01012016, Bal 02012016, Bal 03012016, etc..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an array as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array T1Table{*} T1:;&lt;/P&gt;
&lt;P&gt;T1Last=T1Table[hbound(T1Table)];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which works fine, I am able to get the Hbound and Lbound&amp;nbsp;values, however, I want to be able to figure out how to get the mean from the last 6 months for balances, so basically get the last T1 Value and do the mean calculation against that one and the previous 5 T1 values..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea on how I can achieve this? My array usage is limited so I don't recall.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for the help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jose S&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 20:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297063#M62339</guid>
      <dc:creator>Josers18</dc:creator>
      <dc:date>2016-09-07T20:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY: Avg of Last X Number of Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297068#M62342</link>
      <description>&lt;P&gt;If you have any control of your data structure change it to a long format. Keeping data in a wide format isn't efficient for so many reasons. This becomes trivial if you switch to a long format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you can use some calculations to determine what your field values should be based on your current date and use VVALUE/VVALUEX to retrieve the correct values and average them.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 20:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297068#M62342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-07T20:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY: Avg of Last X Number of Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297069#M62343</link>
      <description>&lt;P&gt;Are your T1 values separate months within one record or are you looking across records?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you define "last 6 months" in terms of the data. There is no indication in your description what may be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 21:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297069#M62343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-07T21:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY: Avg of Last X Number of Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297071#M62344</link>
      <description>&lt;P&gt;If you are sure that the variables are defined in order, here would be an alternate way to get your last one instead of using hbound:&lt;/P&gt;
&lt;P&gt;n_elements = dim(T1Table);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can refer to any array element:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;T1_Last = T1Table{n_elements};&lt;/P&gt;
&lt;P&gt;T1_Back_1mo = T1Table{n_elements-1};&lt;/P&gt;
&lt;P&gt;T1_Back_2mo = T1Table{n_elements-2};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for this to give you the right pieces to work with, you have to be certain that the elements in the array are in order.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 21:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297071#M62344</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-07T21:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY: Avg of Last X Number of Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297074#M62345</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Are your T1 values separate months within one record or are you looking across records?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you define "last 6 months" in terms of the data. There is no indication in your description what may be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Yes sorry about that, The data is sequentially ordered by date. E.G. T1-01012016, T1-02012016, T1-03012016&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I was defining the last 6 months as Hbound - 6 months basically.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 21:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297074#M62345</guid>
      <dc:creator>Josers18</dc:creator>
      <dc:date>2016-09-07T21:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY: Avg of Last X Number of Months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297076#M62346</link>
      <description>&lt;P&gt;Thanks! This worked!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I then did a mean(T1Table{n_elements},......) and it did the trick!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 21:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY-Avg-of-Last-X-Number-of-Months/m-p/297076#M62346</guid>
      <dc:creator>Josers18</dc:creator>
      <dc:date>2016-09-07T21:25:52Z</dc:date>
    </item>
  </channel>
</rss>

