<?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: Select by ID the most recent occurance in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454981#M29344</link>
    <description>&lt;P&gt;Did you try sorting the data&amp;nbsp; and then using LAST. to get the most recent record.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=MC_RESERVATION;
by Confirmation_num Confirmation_Page;

DATA WANT ;
SET MC_RESERVATION;
by Confirmation_num Confirmation_Page;
if last.Confirmation_Page and 20180418&amp;lt;=Departure_day_key&amp;lt;=20180424;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your Confirmation_Page is character then convert it to numeric because if you have values 1,2,11 then sort will be 1,11,2 if the variable is character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why do you have the date values as numeric, best practice is treating them with date formats.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Apr 2018 01:11:28 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-04-18T01:11:28Z</dc:date>
    <item>
      <title>Select by ID the most recent occurance</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454959#M29340</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with transactional data that are labeled for a confirmation_num. These confirmation numbers duplicated each time an update is made to the order by incrementally adding a number to the confirmation_page field. I need to select the most recent occurrence for each confirmation_num.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below brought me back nothing. Thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table t1 as 
SELECT confirmation_num,
input(confirmation_page, best12.) as confirmation_page,
ARRIVAL_DAY_KEY,
DEPARTURE_DAY_KEY
from MC_RESERVATION
where DEPARTURE_DAY_KEY between 20180418 and 20180424
having confirmation_num = max(confirmation_page);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19888i1854D801CD71D944/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 23:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454959#M29340</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-04-17T23:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select by ID the most recent occurance</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454965#M29341</link>
      <description>&lt;P&gt;Maybe this works?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table t1 as 
		SELECT confirmation_num,
			input(confirmation_page, best12.) as confirmation_page,
			ARRIVAL_DAY_KEY,
			DEPARTURE_DAY_KEY
		from MC_RESERVATION
			where DEPARTURE_DAY_KEY between 20180418 and 20180424
				group by confirmation_num
					having confirmation_page = max(confirmation_page)
	;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Apr 2018 23:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454965#M29341</guid>
      <dc:creator>ShenQicheng</dc:creator>
      <dc:date>2018-04-17T23:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select by ID the most recent occurance</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454981#M29344</link>
      <description>&lt;P&gt;Did you try sorting the data&amp;nbsp; and then using LAST. to get the most recent record.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=MC_RESERVATION;
by Confirmation_num Confirmation_Page;

DATA WANT ;
SET MC_RESERVATION;
by Confirmation_num Confirmation_Page;
if last.Confirmation_Page and 20180418&amp;lt;=Departure_day_key&amp;lt;=20180424;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your Confirmation_Page is character then convert it to numeric because if you have values 1,2,11 then sort will be 1,11,2 if the variable is character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why do you have the date values as numeric, best practice is treating them with date formats.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 01:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/454981#M29344</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-18T01:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select by ID the most recent occurance</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/455274#M29372</link>
      <description>&lt;P&gt;Super helpful. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 16:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-by-ID-the-most-recent-occurance/m-p/455274#M29372</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2018-04-18T16:14:23Z</dc:date>
    </item>
  </channel>
</rss>

