<?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 How to keep only the last and the last second observation of a group? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715178#M220887</link>
    <description>I have a liat of students. For each student at a particular tine there is a flag which takes value 0 or 1. The data is sorted in ascending order. Student time flag;&lt;BR /&gt;A.     1:20 0&lt;BR /&gt;A.   1:35.  1&lt;BR /&gt;A      2:40 0&lt;BR /&gt;B.   5:30.  0&lt;BR /&gt;B.    5:35.  0&lt;BR /&gt;B.    6:10.   1&lt;BR /&gt;&lt;BR /&gt;I want to keep only those observations for a student where the flag is 1, and the observation prior to that. Like for this example I want to keep the first two obs for student A and last two for B. &lt;BR /&gt;How fo I achieve this? Please help&lt;BR /&gt;</description>
    <pubDate>Fri, 29 Jan 2021 06:04:38 GMT</pubDate>
    <dc:creator>Shradha1</dc:creator>
    <dc:date>2021-01-29T06:04:38Z</dc:date>
    <item>
      <title>How to keep only the last and the last second observation of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715178#M220887</link>
      <description>I have a liat of students. For each student at a particular tine there is a flag which takes value 0 or 1. The data is sorted in ascending order. Student time flag;&lt;BR /&gt;A.     1:20 0&lt;BR /&gt;A.   1:35.  1&lt;BR /&gt;A      2:40 0&lt;BR /&gt;B.   5:30.  0&lt;BR /&gt;B.    5:35.  0&lt;BR /&gt;B.    6:10.   1&lt;BR /&gt;&lt;BR /&gt;I want to keep only those observations for a student where the flag is 1, and the observation prior to that. Like for this example I want to keep the first two obs for student A and last two for B. &lt;BR /&gt;How fo I achieve this? Please help&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Jan 2021 06:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715178#M220887</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-01-29T06:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep only the last and the last second observation of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715180#M220889</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input student $ time $ flag;
datalines;
A  1:20  0
A  1:35. 1
A  2:40  0
B  5:30. 0
B  5:35. 0
B  6:10. 1
;

data want;
    merge have 
          have(firstobs = 2 keep = flag rename = flag = f);
    if f or flag;
    drop f;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jan 2021 06:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715180#M220889</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-29T06:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep only the last and the last second observation of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715182#M220891</link>
      <description>This helped thanks a lot!!</description>
      <pubDate>Fri, 29 Jan 2021 06:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-only-the-last-and-the-last-second-observation-of-a/m-p/715182#M220891</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-01-29T06:16:10Z</dc:date>
    </item>
  </channel>
</rss>

