<?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: Lag function help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825460#M326057</link>
    <description>&lt;P&gt;Why would you use the KEEPLEN option?&amp;nbsp; Even if the values of those variables are small enough that they will not lose precision when stored in less than the full 8 bytes it is not guaranteed that the SUM will also fit into that smaller space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="n1i6fhy0i39iiln11k9qebhrcq5e" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;KEEPLEN&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that statistics in the output data set inherit the length of the analysis variable that PROC MEANS uses to derive them.&lt;/P&gt;
&lt;SECTION id="n1nw5ghfm8905pn18h3wjfoczasb" class="xisDoc-caution"&gt;
&lt;P class="xisDoc-cautionGenText"&gt;CAUTION&lt;/P&gt;
&lt;P class="xisDoc-cautionLeadin"&gt;You permanently lose numeric precision when the length of the analysis variable causes PROC MEANS to truncate or round the value of the statistic. However, the precision of the statistic matches that of the input.&lt;/P&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;
&lt;DIV id="p04p1a417w0v6qn1dlxvx7abv20o" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;&amp;nbsp;&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 26 Jul 2022 15:36:56 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-07-26T15:36:56Z</dc:date>
    <item>
      <title>Lag function help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825397#M326034</link>
      <description>&lt;P&gt;I am trying to create a dataset so an individual ID will get one row only based on the count of pens and pencils. Maybe this can be solved by the lag function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input ID Pens Pencil;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 0&lt;BR /&gt;2 1 0&amp;nbsp;&lt;BR /&gt;3 1 0&lt;BR /&gt;4 1 0&lt;BR /&gt;5 1 0&lt;BR /&gt;5 0 3&lt;BR /&gt;6 0 1&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input ID Pens Pencil;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 0&lt;BR /&gt;2 1 0&amp;nbsp;&lt;BR /&gt;3 1 0&lt;BR /&gt;4 1 0&lt;BR /&gt;5 1 3&lt;BR /&gt;6 0 1&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 06:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825397#M326034</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2022-07-26T06:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825398#M326035</link>
      <description>&lt;P&gt;One option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have noprint nway;
  class id;
  var pens pencil;
  output out=want(drop=_:) sum= /keeplen;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 06:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825398#M326035</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-07-26T06:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825460#M326057</link>
      <description>&lt;P&gt;Why would you use the KEEPLEN option?&amp;nbsp; Even if the values of those variables are small enough that they will not lose precision when stored in less than the full 8 bytes it is not guaranteed that the SUM will also fit into that smaller space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="n1i6fhy0i39iiln11k9qebhrcq5e" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;KEEPLEN&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that statistics in the output data set inherit the length of the analysis variable that PROC MEANS uses to derive them.&lt;/P&gt;
&lt;SECTION id="n1nw5ghfm8905pn18h3wjfoczasb" class="xisDoc-caution"&gt;
&lt;P class="xisDoc-cautionGenText"&gt;CAUTION&lt;/P&gt;
&lt;P class="xisDoc-cautionLeadin"&gt;You permanently lose numeric precision when the length of the analysis variable causes PROC MEANS to truncate or round the value of the statistic. However, the precision of the statistic matches that of the input.&lt;/P&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;
&lt;DIV id="p04p1a417w0v6qn1dlxvx7abv20o" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;&amp;nbsp;&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 26 Jul 2022 15:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825460#M326057</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-26T15:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825571#M326083</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fair point and agree with what you say. Unfortunately I can't amend the code in the accepted solution anymore to not "propagate" something sub-optimal.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 22:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-help/m-p/825571#M326083</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-07-26T22:53:14Z</dc:date>
    </item>
  </channel>
</rss>

