<?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: How do I compare dates of different formats? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613383#M179118</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268839"&gt;@elli444&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should be the right syntax for LastEvent -&amp;gt; it will give the first day of the month (e.g. 201712 -&amp;gt; 01DEC2017).&lt;/P&gt;
&lt;P&gt;However, what should be the dthdate for&amp;nbsp;1112017? 1JAN2017 or 11NOV2017?&lt;/P&gt;
&lt;P&gt;Another example: 1242017 -&amp;gt; 4DEC2017 or 24JAN2017?&lt;/P&gt;
&lt;P&gt;Is it your raw data or is it possible to import / retrieve them differently?&lt;/P&gt;
&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 ssdmf_checked;
	input dthdate LastEvent;
	datalines;
4152017 201712
1242017 201705
;
run;

data ssdmf_checked_export;
	set ssdmf_checked;
	format dthdate_n LastEvent_n date9.; 
	
	*dthdate_n = input(put(dthdate,z8.),??);
	LastEvent_n = input(put(LastEvent,z6.),yymmn6.);

	if dthdate_n &amp;lt; LastEvent_n then delete;
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Dec 2019 09:39:57 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2019-12-21T09:39:57Z</dc:date>
    <item>
      <title>How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613380#M179117</link>
      <description>&lt;P&gt;Hello I am trying to compare two dates that have two different formats and I am at a loss. My goal is to remove any observations from my dataset where the Death date (dthdate) is before the last date that a lab came in (LastEvent). Both variables are numeric.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dthdate variable is in the format M_D_YYYY. Meaning, there aren't always leading zeroes before the month and day. One variable might be 4152017 (04/15/2017) and another might 1242017 (12/04/2017). I am not sure which format this is in SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The LastEvent variable is in the form YYYYMM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help y'all have to offer is much appreciated. Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code I've been playing with so far. I am trying to do this in a data step if possible.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ssdmf_checked_export;&lt;BR /&gt;set ssdmf_checked;&lt;BR /&gt;&lt;BR /&gt;dthdate_char = PUT(DTHDATE_File1, yymmdd10.);&lt;/P&gt;&lt;P&gt;LastEvent_char = PUT(LAST_EVENT_YM_File2, yymmdd10.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if input(dthdate,mmddyy10.) &amp;lt; input(LastEvent,mmddyy10.);&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 05:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613380#M179117</guid>
      <dc:creator>elli444</dc:creator>
      <dc:date>2019-12-21T05:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613383#M179118</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268839"&gt;@elli444&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should be the right syntax for LastEvent -&amp;gt; it will give the first day of the month (e.g. 201712 -&amp;gt; 01DEC2017).&lt;/P&gt;
&lt;P&gt;However, what should be the dthdate for&amp;nbsp;1112017? 1JAN2017 or 11NOV2017?&lt;/P&gt;
&lt;P&gt;Another example: 1242017 -&amp;gt; 4DEC2017 or 24JAN2017?&lt;/P&gt;
&lt;P&gt;Is it your raw data or is it possible to import / retrieve them differently?&lt;/P&gt;
&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 ssdmf_checked;
	input dthdate LastEvent;
	datalines;
4152017 201712
1242017 201705
;
run;

data ssdmf_checked_export;
	set ssdmf_checked;
	format dthdate_n LastEvent_n date9.; 
	
	*dthdate_n = input(put(dthdate,z8.),??);
	LastEvent_n = input(put(LastEvent,z6.),yymmn6.);

	if dthdate_n &amp;lt; LastEvent_n then delete;
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 09:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613383#M179118</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-21T09:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613397#M179126</link>
      <description>&lt;P&gt;These dates are useless.&amp;nbsp;&lt;SPAN&gt;1242017 could be 12/4/2017 or 1/24/2017.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 15:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613397#M179126</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-21T15:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613398#M179127</link>
      <description>&lt;P&gt;So you have a real problem here.&amp;nbsp; Look at this date:&amp;nbsp; 1242017&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why is it 12/04/217 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Couldn't it be 01/24/2017 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a way to determine that?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 15:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613398#M179127</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-12-21T15:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613601#M179218</link>
      <description>&lt;P&gt;This is very helpful. I think the dthDate is actually just missing the leading zero for the month. So that means _MDDYYYY. Do you know what format that appears as in SAS?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 18:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613601#M179218</guid>
      <dc:creator>elli444</dc:creator>
      <dc:date>2019-12-23T18:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613602#M179219</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268839"&gt;@elli444&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is very helpful. I think the dthDate is actually just missing the leading zero for the month. So that means _MDDYYYY. Do you know what format that appears as in SAS?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then your assumption in your first post that it is December 4 is wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 18:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613602#M179219</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-23T18:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613603#M179220</link>
      <description>&lt;P&gt;Yes, I was mistaken. After looking through the dataset for several examples there are leading zeroes for day but not for month.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 18:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613603#M179220</guid>
      <dc:creator>elli444</dc:creator>
      <dc:date>2019-12-23T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I compare dates of different formats?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613610#M179224</link>
      <description>&lt;P&gt;So, in order to get it right, you should add a leading zero to the string if length is 7, and then use mmddyy8. in the input.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 19:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-compare-dates-of-different-formats/m-p/613610#M179224</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-23T19:34:45Z</dc:date>
    </item>
  </channel>
</rss>

