<?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 Keep the 2 most recent observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-the-2-most-recent-observations/m-p/796629#M255652</link>
    <description>&lt;P&gt;I want to keep data for the 2 most recent observations (variable name: test) for something, but I'm unsure how to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how i would keep the most recent observation, I am just not sure how to get the next one in there too. Especially since have some people with 20 observations and some with only 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by ssn descending test;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 16:50:18 GMT</pubDate>
    <dc:creator>A_Halps</dc:creator>
    <dc:date>2022-02-16T16:50:18Z</dc:date>
    <item>
      <title>Keep the 2 most recent observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-the-2-most-recent-observations/m-p/796629#M255652</link>
      <description>&lt;P&gt;I want to keep data for the 2 most recent observations (variable name: test) for something, but I'm unsure how to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how i would keep the most recent observation, I am just not sure how to get the next one in there too. Especially since have some people with 20 observations and some with only 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by ssn descending test;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-the-2-most-recent-observations/m-p/796629#M255652</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2022-02-16T16:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Keep the 2 most recent observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-the-2-most-recent-observations/m-p/796636#M255658</link>
      <description>Add an enumeration counter and filter based on that.&lt;BR /&gt;&lt;A href="https://stats.oarc.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/" target="_blank"&gt;https://stats.oarc.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by ssn descending test;&lt;BR /&gt;if first.ssn then count=0;&lt;BR /&gt;count+1;&lt;BR /&gt;if count&amp;lt;=2;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 16 Feb 2022 17:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-the-2-most-recent-observations/m-p/796636#M255658</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-16T17:07:31Z</dc:date>
    </item>
  </channel>
</rss>

