<?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: Subset Data / Date Compare and Pick the Oldest in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529705#M144772</link>
    <description>&lt;P&gt;I would like you to explain&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What if&lt;/STRONG&gt; dif&amp;lt;=7 in some transactions and dif&amp;gt;7&amp;nbsp; in other transactions for the same customer_id?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" style="height: 133px;" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TH class="l header" style="height: 19px; width: 88px;" scope="col"&gt;Customer_ID&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 101px;" scope="col"&gt;Transaction_ID&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 81px;" scope="col"&gt;ServiceDate&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 40px;" scope="col"&gt;dif&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB1&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;12345&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;10/12/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB1&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;12346&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;10/14/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB1&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;12347&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;10/15/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB2&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;22233&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;06/10/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB2&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;22234&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;09/12/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;94&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB3&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;35678&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;01/05/2019&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 24 Jan 2019 15:04:25 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-24T15:04:25Z</dc:date>
    <item>
      <title>Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529701#M144770</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to subset the Input Table by comparing the Service Date of each Customer_ID.&lt;/P&gt;&lt;P&gt;If difference in Service Date of a Customer_ID is within 7 days, then select only the observation with oldest date.&lt;/P&gt;&lt;P&gt;If difference in Service Date is more than 7 days then select all the observations. Please see the Input and Output Tables below and help me with the Code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Input Table&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Customer_ID&lt;/TD&gt;&lt;TD&gt;Transaction_ID&lt;/TD&gt;&lt;TD&gt;Service Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AB1&lt;/TD&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;10/12/18&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&g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lt;/TD&gt;&lt;TD&gt;22234&lt;/TD&gt;&lt;TD&gt;9/12/18&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AB3&lt;/TD&gt;&lt;TD&gt;35678&lt;/TD&gt;&lt;TD&gt;1/5/19&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Varun&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 14:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529701#M144770</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-01-24T14:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529705#M144772</link>
      <description>&lt;P&gt;I would like you to explain&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What if&lt;/STRONG&gt; dif&amp;lt;=7 in some transactions and dif&amp;gt;7&amp;nbsp; in other transactions for the same customer_id?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" style="height: 133px;" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TH class="l header" style="height: 19px; width: 88px;" scope="col"&gt;Customer_ID&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 101px;" scope="col"&gt;Transaction_ID&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 81px;" scope="col"&gt;ServiceDate&lt;/TH&gt;
&lt;TH class="r header" style="height: 19px; width: 40px;" scope="col"&gt;dif&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB1&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;12345&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;10/12/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB1&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;12346&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;10/14/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB1&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;12347&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;10/15/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB2&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;22233&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;06/10/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB2&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;22234&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;09/12/2018&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;94&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD class="l data" style="height: 19px; width: 88px;"&gt;AB3&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 101px;"&gt;35678&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 81px;"&gt;01/05/2019&lt;/TD&gt;
&lt;TD class="r data" style="height: 19px; width: 40px;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 24 Jan 2019 15:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529705#M144772</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-24T15:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529713#M144777</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide your sample data in the form of a datastep, this will help more number of people responding with spending their little time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dlm='09'x dsd;
input Customer_ID $	Transaction_ID	Service_Date mmddyy8.;
format Service_Date mmddyy10.;
datalines;
AB1	12345	10/12/18
AB1	12346	10/14/18
AB1	12347	10/15/18
AB2	22233	6/10/18
AB2	22234	9/12/18
AB3	35678	1/5/19
;
run;

proc sort data=have;
by Customer_ID 	Transaction_ID	descending Service_Date;
run;

data have_dif;
set have;
by Customer_ID 	Transaction_ID	descending Service_Date;
dif_dt=dif(Service_Date);
if first.Customer_ID then dif_dt=0;
run;

proc sql;
select Customer_ID ,Transaction_ID,Service_Date
	from have_dif
	where customer_id in (select customer_id from have_dif where dif_dt&amp;gt;7)
union 
select Customer_ID ,Transaction_ID,Service_Date
	from have_dif
	where customer_id not in (select customer_id from have_dif where dif_dt&amp;gt;7)
group by Customer_ID
	having Service_Date=min(Service_Date)
order by customer_id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 15:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529713#M144777</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-01-24T15:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529716#M144778</link>
      <description>&lt;P&gt;You want to drop a transaction that is within 7 days of the prior transaction (presumably you want this date interval honored only WITHIN id's, not BETWEEN id's - that's &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s question):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Customer_ID :$3. Transaction_ID Service_Date  :mmddyy8.;
  format service_date date9.;
datalines;;
AB1 12345 10/12/18 
AB1 12346 10/14/18 
AB1 12347 10/15/18 
AB2 22233 6/10/18 
AB2 22234 9/12/18 
AB3 35678 1/5/19 
run;
data want (drop=last_output_date);
  set have ;
  by customer_id;
  if first.customer_id
    or service_date-7 &amp;gt; last_output_date;
  output;
  last_output_date=service_date;
  retain last_output_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program creates a variable LAST_OUTPUT_DATE, preserving the most recent date that passes your criterion.&amp;nbsp; It is RETAINed across observations (not automatically reset to missing at top of data step), making it possible for you to compare the observation in hand to some previously generated value.&amp;nbsp; This is necessary because you can't just compare one date to the immediately prior date - instead you may have to compare it to a date further back than the prior date.&amp;nbsp; That's the situation for id AB1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IF statement above has no THEN clause.&amp;nbsp; Therefore it is a &lt;EM&gt;&lt;STRONG&gt;subsetting if&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; Only observations meeting the if condition are processed further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 15:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529716#M144778</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-01-24T15:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529717#M144779</link>
      <description>&lt;P&gt;"help me with the code" can mean a lot of things, anything from:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL style="list-style-position: inside;"&gt;
&lt;LI&gt;I got an error that I don't know how to fix, to&lt;/LI&gt;
&lt;LI&gt;I have no idea what to do, so write it for me&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If I were writing the code, I would begin with a simple step.&amp;nbsp; Assuming the data set is in sorted order by Customer_ID, and assuming that Service_Date is an actual SAS date and not a character string:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have;&lt;/P&gt;
&lt;P&gt;by customer_ID;&lt;/P&gt;
&lt;P&gt;var Service_Date;&lt;/P&gt;
&lt;P&gt;output out=ranges (keep=customer_ID First_Date Last_Date) min=first_date max=last_date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you a SAS data set with one observation per Customer_ID, with the first and last date of service for that customer.&amp;nbsp; If you had such a SAS data set, would you have any idea of what you need to do next?&amp;nbsp; Are you able to outline a plan (not necessarily write the program)?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 15:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529717#M144779</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-24T15:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529721#M144780</link>
      <description>&lt;P&gt;That's is a great question. I did not think of that before.&lt;/P&gt;&lt;P&gt;Thanks for asking.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If diff is greater than 7 than I would like the Service Date to be compared with the last selected observation and perform the same logic.&lt;/P&gt;&lt;P&gt;Here, I have modified the Input and Output example. Hope this will make it clear and it's the same thing you were asking :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Input Table&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Customer_ID&lt;/TD&gt;&lt;TD&gt;Transaction_ID&lt;/TD&gt;&lt;TD&gt;Service Date&lt;/TD&gt;&lt;TD&gt;Diff&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;T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P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 15:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529721#M144780</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-01-24T15:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529730#M144784</link>
      <description>Thanks for you reply. I meant - I have no idea.&lt;BR /&gt;Service_Date is not actual SAS Date.&lt;BR /&gt;I am hoping to get more than one observation per Customer_ID.</description>
      <pubDate>Thu, 24 Jan 2019 16:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529730#M144784</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-01-24T16:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529733#M144786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194984"&gt;@VarunD&lt;/a&gt;&amp;nbsp; I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp; comprehended your need pretty well. Play with his solution and see if that works. If I were to take a stab, might partially plagiarize on his idea as that datastep gives a beautiful start. If that solution requires tweaking and Mark happens to be busy, I will chime in.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 16:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529733#M144786</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-24T16:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529736#M144789</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194984"&gt;@VarunD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;... &lt;BR /&gt;Service_Date is not actual SAS Date.&lt;BR /&gt;...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But Service_Date becomes a SAS date&lt;SPAN style="text-decoration: line-through;"&gt;a&lt;/SPAN&gt; via the INPUT statement below, which tells sas to interpret that field with the MMDDYY8. inbound format.&amp;nbsp; This means that sas converts the input field to a sas date&lt;SPAN style="text-decoration: line-through;"&gt;a&lt;/SPAN&gt; value (a value recording the number of days after or before 1/1/1960).&amp;nbsp; You can make these numbers easy to visually interpret by assign a FORMAT to the variable, so that you can realize what the date is for that date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Customer_ID :&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; Transaction_ID Service_Date  :mmddyy8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; service_date date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once this date value is constructed, then a subtraction between two values is the number of days by which they are separated.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 16:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529736#M144789</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-01-24T16:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529754#M144797</link>
      <description>This seems to have worked. I will have to verify the output that might take some time. But this looks good. Thanks a lot !</description>
      <pubDate>Thu, 24 Jan 2019 16:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529754#M144797</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-01-24T16:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subset Data / Date Compare and Pick the Oldest</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529756#M144799</link>
      <description>Thanks for your response! I will ensure that I provide data in datastep for next time.</description>
      <pubDate>Thu, 24 Jan 2019 16:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-Data-Date-Compare-and-Pick-the-Oldest/m-p/529756#M144799</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-01-24T16:58:06Z</dc:date>
    </item>
  </channel>
</rss>

