<?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: Equivalence using DATETIME in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224894#M5381</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Beautiful!&amp;nbsp; That works perfectly.&amp;nbsp; Thanks a lot.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Sep 2015 03:17:16 GMT</pubDate>
    <dc:creator>n6</dc:creator>
    <dc:date>2015-09-10T03:17:16Z</dc:date>
    <item>
      <title>Equivalence using DATETIME</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224868#M5377</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have code that does the following sort of thing over and over:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if SUBJECT_NUMBER='300-0010' then do; &lt;BR /&gt; if input ('19AUG15:07:52:00', DateTime18.) &amp;lt;= Event_Time &amp;lt;= input ('20AUG15:07:30:00', DateTime18.) then AUC_Day_1 = 1; &lt;BR /&gt; if input ('20AUG15:07:30:00', DateTime18.) &amp;lt;= Event_Time &amp;lt;= input ('21AUG15:07:45:00', DateTime18.) then AUC_Day_2 = 1; &lt;BR /&gt;end; &lt;/P&gt;
&lt;P&gt;I expect the result to look like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Day_1&amp;nbsp;&amp;nbsp; Day_2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&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; 1&lt;/P&gt;
&lt;P&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; 1&lt;/P&gt;
&lt;P&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; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words, the largest value in one interval and the smallest value in the other are the same.&amp;nbsp; So one will be 1 and the other will be missing except for when we hit that one overlapping value, at that point both Day_1 and Day_2 should be 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mysteriously, sometimes I get the above but sometimes I don't and instead get only one of the other with a value of 1 at the point where the intervals overlap.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's basically like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;&amp;nbsp; 5&amp;nbsp; &amp;lt;=&amp;nbsp; x&amp;nbsp; &amp;lt;= 10 then S = 1;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp; 10 &amp;lt;=&amp;nbsp; x&amp;nbsp; &amp;lt;= 20 then T = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to me that when x is 10, both S and T must be 1.&amp;nbsp; And yet I'm only getting it some of the time.&amp;nbsp; It's not typos on the datetimes that overlap because I'm copying them from elsewhere and then pasting them in the two places in the code.&amp;nbsp; And plus I can look at them with my eyes and see they are the same.&amp;nbsp; I am mystified.&amp;nbsp; Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 00:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224868#M5377</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2015-09-10T00:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Equivalence using DATETIME</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224883#M5378</link>
      <description>&lt;P&gt;If Event_Time is a SAS datetime, then you should compare it with SAS datetime constants, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if SUBJECT_NUMBER='300-0010' then do; 
	if '19AUG15:07:52:00'DT &amp;lt;= Event_Time &amp;lt;= '20AUG15:07:30:00'DT then AUC_Day_1 = 1; 
	if '20AUG15:07:30:00'DT &amp;lt;= Event_Time &amp;lt;= '21AUG15:07:45:00'DT then AUC_Day_2 = 1; 
	end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 02:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224883#M5378</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-09-10T02:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Equivalence using DATETIME</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224891#M5379</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the suggestion but when I try it that way I get the same result, namely some are good and some are not.&amp;nbsp; I notice that the example code I posted happened to be one of the good ones so here is one of the bad ones to balance it out, although why one is good and one is bad is a mystery to me.&amp;nbsp; I'll post it both the way I originally coded it and with the DT suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if SUBJECT_NUMBER='300-0002' then do; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if '12AUG15:08:10:00'DT &amp;lt;= Event_Time &amp;lt;= '13AUG15:07:10:00'DT then AUC_Day_1 = 1; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if '13AUG15:07:10:00'DT &amp;lt;= Event_Time &amp;lt;= '14AUG15:09:36:00'DT then AUC_Day_2 = 1; &lt;BR /&gt; end; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if SUBJECT_NUMBER='300-0002' then do; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; if input ('12AUG15:08:10:00', DateTime18.) &amp;lt;= Event_Time &amp;lt;= input ('13AUG15:07:10:00', DateTime18.) then AUC_Day_1 = 1; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; if input ('13AUG15:07:10:00', DateTime18.) &amp;lt;= Event_Time &amp;lt;= input ('14AUG15:09:36:00', DateTime18.) then AUC_Day_2 = 1; &lt;BR /&gt; end; &lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 02:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224891#M5379</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2015-09-10T02:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Equivalence using DATETIME</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224893#M5380</link>
      <description>&lt;P&gt;OK, then it could be that Event_Time is not always an integer. This happens to me when I import/convert dates from Excel. Try this then:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if SUBJECT_NUMBER='300-0010' then do; 
	if '19AUG15:07:52:00'DT &amp;lt;= round(Event_Time) &amp;lt;= '20AUG15:07:30:00'DT then AUC_Day_1 = 1; 
	if '20AUG15:07:30:00'DT &amp;lt;= round(Event_Time) &amp;lt;= '21AUG15:07:45:00'DT then AUC_Day_2 = 1; 
	end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 03:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224893#M5380</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-09-10T03:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Equivalence using DATETIME</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224894#M5381</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Beautiful!&amp;nbsp; That works perfectly.&amp;nbsp; Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 03:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Equivalence-using-DATETIME/m-p/224894#M5381</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2015-09-10T03:17:16Z</dc:date>
    </item>
  </channel>
</rss>

