<?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: Capturing the first and last date record into new tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557277#M155316</link>
    <description>&lt;P&gt;Thank you, this did exactly what I was looking for, much appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2019 20:13:18 GMT</pubDate>
    <dc:creator>Sas_Act_114</dc:creator>
    <dc:date>2019-05-08T20:13:18Z</dc:date>
    <item>
      <title>Capturing the first and last date record into new tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557272#M155312</link>
      <description>&lt;P&gt;I have a very large table with ID numbers and dates associated with them. As as example of a table with two columns (I will use names instead of ID numbers for simplicity):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; 1/1/2010&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; 1/1/2011&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; 1/1/2012&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; 1/1/2013&lt;/P&gt;&lt;P&gt;Sam&amp;nbsp; &amp;nbsp; &amp;nbsp;6/1/2012&lt;/P&gt;&lt;P&gt;Sam&amp;nbsp; &amp;nbsp; &amp;nbsp;4/1/2013&lt;/P&gt;&lt;P&gt;Sam&amp;nbsp; &amp;nbsp; &amp;nbsp;4/1/2014&lt;/P&gt;&lt;P&gt;Victor&amp;nbsp; &amp;nbsp;7/1/2011&lt;/P&gt;&lt;P&gt;Zack&amp;nbsp; &amp;nbsp; 4/1/2011&lt;/P&gt;&lt;P&gt;Zack&amp;nbsp; &amp;nbsp; 4/1/2012&lt;/P&gt;&lt;P&gt;Zack&amp;nbsp; &amp;nbsp; 10/1/2012&lt;/P&gt;&lt;P&gt;Zack&amp;nbsp; &amp;nbsp; 10/1/2013&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this table, I want to make two tables - One that has the name and the earliest date associated to that name (member ID) and one that has the name and the last date associated to that name. Thus the first table would come out as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; 1/1/2010&lt;/P&gt;&lt;P&gt;Sam&amp;nbsp; &amp;nbsp; &amp;nbsp;6/1/2012&lt;/P&gt;&lt;P&gt;Victor&amp;nbsp; &amp;nbsp;7/1/2011&lt;/P&gt;&lt;P&gt;Zack&amp;nbsp; &amp;nbsp; 4/1/2011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the second table (with the last date) would come out as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; 1/1/2013&lt;/P&gt;&lt;P&gt;Sam&amp;nbsp; &amp;nbsp; &amp;nbsp;4/1/2014&lt;/P&gt;&lt;P&gt;Victor&amp;nbsp; &amp;nbsp;7/1/2011&lt;/P&gt;&lt;P&gt;Zack&amp;nbsp; &amp;nbsp; 10/1/2013&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've included the example of "Victor" as there are records with just one date, thus the same date would have to count as both the first and last. Thank you to any that see this and can help!&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 19:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557272#M155312</guid>
      <dc:creator>Sas_Act_114</dc:creator>
      <dc:date>2019-05-08T19:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the first and last date record into new tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557273#M155313</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dataset1 dataset2;
    set have;
    by id;
    if first.id then output dataset1;
    if last.id then output dataset2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 19:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557273#M155313</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-08T19:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the first and last date record into new tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557274#M155314</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
   input name:$8. date:mmddyy.;
   format date mmddyy.;
   cards;
John    1/1/2010
John    1/1/2011
John    1/1/2012
John    1/1/2013
Sam     6/1/2012
Sam     4/1/2013
Sam     4/1/2014
Victor   7/1/2011
Zack    4/1/2011
Zack    4/1/2012
Zack    10/1/2012
Zack    10/1/2013
;;;;
   run;
proc summary data=dates nway missing;
   class name;
   output out=want(drop=_) min(date)=first max(date)=last;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 19:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557274#M155314</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-05-08T19:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the first and last date record into new tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557276#M155315</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input name:$8. date:mmddyy.;
   format date mmddyy.;
   cards;
John    1/1/2010
John    1/1/2011
John    1/1/2012
John    1/1/2013
Sam     6/1/2012
Sam     4/1/2013
Sam     4/1/2014
Victor   7/1/2011
Zack    4/1/2011
Zack    4/1/2012
Zack    10/1/2012
Zack    10/1/2013
;;;;
   run;

proc sql;
create table  earliest_date as
select *
from have
group name
having date=min(date);
quit;

proc sql;
create table latest_date as
select *
from have
group name
having date=max(date);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 20:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557276#M155315</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-08T20:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the first and last date record into new tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557277#M155316</link>
      <description>&lt;P&gt;Thank you, this did exactly what I was looking for, much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 20:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-the-first-and-last-date-record-into-new-tables/m-p/557277#M155316</guid>
      <dc:creator>Sas_Act_114</dc:creator>
      <dc:date>2019-05-08T20:13:18Z</dc:date>
    </item>
  </channel>
</rss>

