<?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: can you sum a lag? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/can-you-sum-a-lag/m-p/74601#M21665</link>
    <description>It would be easier you would provide us your code.&lt;BR /&gt;
&lt;BR /&gt;
But may be the following gives you the hint you need.&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
  do x1=1 to 5;&lt;BR /&gt;
    x2=10*x1;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  retain x2sum;&lt;BR /&gt;
  x2sum=sum(x2sum,x2);&lt;BR /&gt;
  sumvar=sum(x1*lag(x1), x2*x2sum);&lt;BR /&gt;
  put x1= x2= x2sum= sumvar=;&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 06 Oct 2009 22:07:21 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2009-10-06T22:07:21Z</dc:date>
    <item>
      <title>can you sum a lag?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/can-you-sum-a-lag/m-p/74600#M21664</link>
      <description>I'm trying to do the following&lt;BR /&gt;
&lt;BR /&gt;
sum(x1*lag(x1), x2*sum(x2),,);&lt;BR /&gt;
&lt;BR /&gt;
x1 etc are macro variables actually &amp;amp;var&amp;amp;&amp;amp;z.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm thinking that I need some way to pass the lagged value into the sum function.  All my tests seem to indicate just saying sum(lag(x1)) does not pass a value</description>
      <pubDate>Tue, 06 Oct 2009 21:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/can-you-sum-a-lag/m-p/74600#M21664</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-06T21:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: can you sum a lag?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/can-you-sum-a-lag/m-p/74601#M21665</link>
      <description>It would be easier you would provide us your code.&lt;BR /&gt;
&lt;BR /&gt;
But may be the following gives you the hint you need.&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
  do x1=1 to 5;&lt;BR /&gt;
    x2=10*x1;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  retain x2sum;&lt;BR /&gt;
  x2sum=sum(x2sum,x2);&lt;BR /&gt;
  sumvar=sum(x1*lag(x1), x2*x2sum);&lt;BR /&gt;
  put x1= x2= x2sum= sumvar=;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 06 Oct 2009 22:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/can-you-sum-a-lag/m-p/74601#M21665</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2009-10-06T22:07:21Z</dc:date>
    </item>
  </channel>
</rss>

