<?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: How do i get cumulative decayed sum? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763229#M241699</link>
    <description>&lt;P&gt;Not real sure this approach will work, but you might try arranging your data&amp;nbsp; so that each desumy and y are read in as input, and desumy_t is a dependent variable.&amp;nbsp; Then you could fit this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;desumy_t = (desumy_t-1 + y_t-1)*prho;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;assuming some sort of count related distribution (poisson, negbin or generalized poisson).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SteveDenham&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Aug 2021 13:13:50 GMT</pubDate>
    <dc:creator>SteveDenham</dc:creator>
    <dc:date>2021-08-23T13:13:50Z</dc:date>
    <item>
      <title>How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763030#M241634</link>
      <description>&lt;P&gt;Hi I am currently struggling to get a cumulative 'decayed' sum of variables.&lt;/P&gt;&lt;P&gt;For example, if variable y has value like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;day&amp;nbsp; y&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to get a variable 'desumy', by each person (let's assume that example that i brought is from a single person),&amp;nbsp; assuming that decaying rate is 0.5 in a day:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;day&amp;nbsp; y&amp;nbsp; &amp;nbsp;desumy&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; 4*0.5&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; 4*0.5*0.5 + 3*0.5&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;4*0.5*0.5*0.5 + 3*0.5*0.5&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;4*0.5*0.5*0.5 + 3*0.5*0.5&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i figured out that all i have to do is to create variable 'desumy' that satisfies&lt;/P&gt;&lt;P&gt;desumy_t = (desumy_t-1 + y_t-1)*0.5, but i am struggling to make a code implementing what i want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 10:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763030#M241634</guid>
      <dc:creator>Jhpark1222</dc:creator>
      <dc:date>2021-08-21T10:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763031#M241635</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input day  y;
cards;
1      4
2      3
3      2
4      6
5      1
6      2
;

data want;
 set have;
 retain  lag_desumy 0;
 desumy=sum(lag_desumy,lag(y))*0.5;
 lag_desumy=desumy;
 drop lag_desumy;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Aug 2021 11:21:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763031#M241635</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-21T11:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763044#M241636</link>
      <description>&lt;P&gt;Just use retain and lag().&amp;nbsp; It is even easier if you use a sum statement as then the target variable of the sum statement is automatically retained.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  desumy + lag(y)*0.5 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Aug 2021 13:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763044#M241636</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-21T13:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763062#M241639</link>
      <description>&lt;P&gt;Thanks a lot for your reply.&lt;/P&gt;&lt;P&gt;I am trying to use this in&lt;STRONG&gt; proc nlmixed&lt;/STRONG&gt; in order to estimate maximum likelihood, but in proc nlmixed, 'retain ' seems to not work.&lt;/P&gt;&lt;P&gt;0.5 in my original question was decay rate phro, which is a parameter that needs to be estimated through maximum likelihood estimation process.&lt;/P&gt;&lt;P&gt;is there any advice?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 16:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763062#M241639</guid>
      <dc:creator>Jhpark1222</dc:creator>
      <dc:date>2021-08-21T16:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763063#M241640</link>
      <description>&lt;P&gt;Thanks a lot for your reply.&lt;/P&gt;&lt;P&gt;I am trying to use this in&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;proc nlmixed&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in order to estimate maximum likelihood, but in proc nlmixed, 'retain ' seems to not work.&lt;/P&gt;&lt;P&gt;0.5 in my original question was decay rate phro, which is a parameter that needs to be estimated through maximum likelihood estimation process.&lt;/P&gt;&lt;P&gt;is there any advice?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 16:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763063#M241640</guid>
      <dc:creator>Jhpark1222</dc:creator>
      <dc:date>2021-08-21T16:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763135#M241660</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13758"&gt;@lvm&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Aug 2021 09:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763135#M241660</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-22T09:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do i get cumulative decayed sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763229#M241699</link>
      <description>&lt;P&gt;Not real sure this approach will work, but you might try arranging your data&amp;nbsp; so that each desumy and y are read in as input, and desumy_t is a dependent variable.&amp;nbsp; Then you could fit this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;desumy_t = (desumy_t-1 + y_t-1)*prho;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;assuming some sort of count related distribution (poisson, negbin or generalized poisson).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SteveDenham&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 13:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-get-cumulative-decayed-sum/m-p/763229#M241699</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2021-08-23T13:13:50Z</dc:date>
    </item>
  </channel>
</rss>

