<?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 why the answer is 8 ? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836304#M82103</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.numbers;
infile datalines;
input T;
datalines;
6
7
8
;
proc print data = work.numbers noobs;
run;

title 'sum of lag';
data work.move;
  set work.numbers;
  if _N_= 3 then total=sum(T,lag1(T),lag2(T));
run;
proc print data = work.move noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 01 Oct 2022 16:10:53 GMT</pubDate>
    <dc:creator>tianerhu</dc:creator>
    <dc:date>2022-10-01T16:10:53Z</dc:date>
    <item>
      <title>why the answer is 8 ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836304#M82103</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.numbers;
infile datalines;
input T;
datalines;
6
7
8
;
proc print data = work.numbers noobs;
run;

title 'sum of lag';
data work.move;
  set work.numbers;
  if _N_= 3 then total=sum(T,lag1(T),lag2(T));
run;
proc print data = work.move noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Oct 2022 16:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836304#M82103</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2022-10-01T16:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: why the answer is 8 ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836305#M82104</link>
      <description>&lt;P&gt;Because you commit the #1 capital sin of LAG: using the function conditionally. The LAG functions will only populate their queue when actually called, so you put nothing into the queue until the third observation, where the result is still missing.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Oct 2022 16:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836305#M82104</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-01T16:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: why the answer is 8 ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836308#M82107</link>
      <description>Thank you for your help.</description>
      <pubDate>Sat, 01 Oct 2022 16:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836308#M82107</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2022-10-01T16:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: why the answer is 8 ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836386#M82108</link>
      <description>&lt;P&gt;Looks like you want this program instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.numbers;
  input T;
datalines;
6
7
8
;
data work.move;
  set work.numbers;
  total=sum(T,lag1(T),lag2(T));
  if _N_&amp;lt; 3 then call missing(total);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Oct 2022 14:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/why-the-answer-is-8/m-p/836386#M82108</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-02T14:24:18Z</dc:date>
    </item>
  </channel>
</rss>

