<?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: retain the last value by group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782201#M249362</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by place;
retain retain_obs;
if first.place then retain_obs = .;
if obs ne 0 then retain_obs = obs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Nov 2021 12:01:20 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-11-24T12:01:20Z</dc:date>
    <item>
      <title>retain the last value by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782199#M249361</link>
      <description>&lt;P&gt;Hi folks&lt;/P&gt;&lt;P&gt;I want some observations (obs)&amp;nbsp; by group (place) and time (timepoint)&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input place $ timepoint obs;
datalines;
a  1.1   0
a  1.2   0
a  1.3   1
a  1.4   0
a  1.5   0
b  1.1   0
b  1.2   1
b  1.3   0
b  1.4   2
b  1.5   0
;
run;

data want;
set have;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want is to retain the last obs by place to the dataset looks like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="clip.jpg" style="width: 300px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66079i4077E34126D605F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="clip.jpg" alt="clip.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any idea on how to do this ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 11:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782199#M249361</guid>
      <dc:creator>Claus_Stenberg</dc:creator>
      <dc:date>2021-11-24T11:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: retain the last value by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782201#M249362</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by place;
retain retain_obs;
if first.place then retain_obs = .;
if obs ne 0 then retain_obs = obs;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Nov 2021 12:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782201#M249362</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-24T12:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: retain the last value by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782431#M249427</link>
      <description>&lt;P&gt;Thanks a lot - nice and simple. Works like a charm &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 12:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-the-last-value-by-group/m-p/782431#M249427</guid>
      <dc:creator>Claus_Stenberg</dc:creator>
      <dc:date>2021-11-25T12:28:15Z</dc:date>
    </item>
  </channel>
</rss>

