<?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: Adding values in a variable based on the values in the other variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681849#M206312</link>
    <description>&lt;P&gt;What shoild the output look like in terms of variables and observations?&lt;/P&gt;
&lt;P&gt;Should it start the first time the rolling window is filled with 5 values, or should the months before that appear with the sum of 1,2,3,4 values?&lt;/P&gt;</description>
    <pubDate>Sun, 06 Sep 2020 06:34:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-09-06T06:34:24Z</dc:date>
    <item>
      <title>Adding values in a variable based on the values in the other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681843#M206309</link>
      <description>&lt;P&gt;Hi, I am trying to add the values of mnth in the order of code starting from 1 to 5, the 2 to 6, 3 to 7 etc. Any help in doing this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data score;&lt;BR /&gt;input code mnth yr;&lt;BR /&gt;datalines;&lt;/P&gt;&lt;P&gt;1 1.1 25&lt;BR /&gt;2 1.2 26&lt;BR /&gt;3 1.3 25&lt;BR /&gt;4 2.1 24&lt;BR /&gt;5 3.2 26&lt;BR /&gt;6 3.4 67&lt;BR /&gt;7 5.6 56&lt;BR /&gt;8 6 34&lt;BR /&gt;9 7 45&lt;/P&gt;&lt;P&gt;9 7 45&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Sep 2020 02:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681843#M206309</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-09-06T02:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values in a variable based on the values in the other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681849#M206312</link>
      <description>&lt;P&gt;What shoild the output look like in terms of variables and observations?&lt;/P&gt;
&lt;P&gt;Should it start the first time the rolling window is filled with 5 values, or should the months before that appear with the sum of 1,2,3,4 values?&lt;/P&gt;</description>
      <pubDate>Sun, 06 Sep 2020 06:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681849#M206312</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-06T06:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values in a variable based on the values in the other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681922#M206355</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;It should start the first time the rolling window is filled with 5 values.&lt;BR /&gt;Ex:&lt;BR /&gt;Roll1to5 8.9&lt;BR /&gt;Roll2to6 11.2&lt;BR /&gt;Roll3to6 ......etc.&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Sep 2020 01:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681922#M206355</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-09-07T01:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding values in a variable based on the values in the other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681971#M206377</link>
      <description>&lt;P&gt;First, we need to make sure we only have one observation per code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=score;
by code;
var mth;
output out=comp (drop=_type_ _freq_) sum()=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, we create the rolling window with a temporary array, and start outputting once it is filled:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set comp;
array vals {5} _temporary_;
vals{mod(_n_,5)+1} = mnth;
if _n_ ge 5;
mnth = sum (of vals{*});
keep code mnth;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 08:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-values-in-a-variable-based-on-the-values-in-the-other/m-p/681971#M206377</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-07T08:25:09Z</dc:date>
    </item>
  </channel>
</rss>

