<?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: SAS datatime variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101167#M28396</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your replies but I'm still not getting it. So if I have 2 datetime variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X=22MAY13:10:44:00&lt;/P&gt;&lt;P&gt;Y=22MAY12:10:44:15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to effectively default the Y seconds to 00 so that I apply a X=Y condition that is applied down to the minute component.&lt;/P&gt;&lt;P&gt;(I expect Im being dumb.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Aug 2013 09:08:43 GMT</pubDate>
    <dc:creator>Mikeyjh</dc:creator>
    <dc:date>2013-08-08T09:08:43Z</dc:date>
    <item>
      <title>SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101163#M28392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 SAS datatime fields - variable X collects a seconds component and variable Y does not (Y reports seconds as :00). How can I convert variable X so that it has a 00 seconds component so that I can compare the values as X = Y (so matches within DMYHM components only)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 14:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101163#M28392</guid>
      <dc:creator>Mikeyjh</dc:creator>
      <dc:date>2013-08-05T14:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101164#M28393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have two datetime columns, then they both include seconds.&amp;nbsp; Don't confuse the format with the underlying value.&amp;nbsp; You can convert a date variable into a datetime by using the dhms function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dhms('05Aug2013'd,0,0,0)='05Aug2013:0:0'dt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 15:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101164#M28393</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-08-05T15:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101165#M28394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can remove the time part of a datetime value a number of way.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; X='01JAN2013:12:30'dt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; Y='01JAN2013:00:00'dt ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;* Use DATEPART() function on both variables. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if datepart(X) = datepart(Y) then put '1 equal';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;* Use INTNX() function to "round" the value ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if&amp;nbsp; y = intnx('dtday',x,0) then put '2 equal';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;* Use DATEPART() and DHMS() functions on one. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if y = dhms(datepart(X),0,0,0) then put '3 equal';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 15:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101165#M28394</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-08-05T15:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101166#M28395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If variety is the spice of life:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if y = x - mod(x,60) then put '4 equal';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It also makes a difference as to what Y actually contains.&amp;nbsp; If the actual time would have been at the 59 second mark, would the seconds be ignored or would the minutes be rounded upward?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 16:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101166#M28395</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-08-05T16:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101167#M28396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your replies but I'm still not getting it. So if I have 2 datetime variables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X=22MAY13:10:44:00&lt;/P&gt;&lt;P&gt;Y=22MAY12:10:44:15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to effectively default the Y seconds to 00 so that I apply a X=Y condition that is applied down to the minute component.&lt;/P&gt;&lt;P&gt;(I expect Im being dumb.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 09:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101167#M28396</guid>
      <dc:creator>Mikeyjh</dc:creator>
      <dc:date>2013-08-08T09:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101168#M28397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following will create a variable X1 which contains an augmented version of the X variable with the seconds converted to 0 - which is what the 4th argument in the DHMS statement represents.&amp;nbsp; You can then compare the Y and X1 variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;MATCH = 0;&lt;/P&gt;&lt;P&gt;X="22MAY13:10:44:15"DT;&lt;/P&gt;&lt;P&gt;Y="22MAY13:10:44:00"DT;&lt;/P&gt;&lt;P&gt;X1=DHMS(DATEPART(X),HOUR(X),MINUTE(X),0);&lt;/P&gt;&lt;P&gt;IF Y = X1 THEN MATCH = 1;&lt;/P&gt;&lt;P&gt;FORMAT X X1 Y DATETIME18.;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course you could also do the following, which negates the need for the additional variable.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;MATCH = 0;&lt;/P&gt;&lt;P&gt;X="22MAY13:10:44:15"DT;&lt;/P&gt;&lt;P&gt;Y="22MAY13:10:44:00"DT;&lt;/P&gt;&lt;P&gt;IF Y = DHMS(DATEPART(X),HOUR(X),MINUTE(X),0) THEN MATCH = 1;&lt;/P&gt;&lt;P&gt;FORMAT X Y DATETIME18.;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Removed Timepart references as they are not necessary.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 09:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101168#M28397</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-08-08T09:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101169#M28398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Scott. So easy now I see what you've done.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 10:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101169#M28398</guid>
      <dc:creator>Mikeyjh</dc:creator>
      <dc:date>2013-08-08T10:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101170#M28399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;INTNX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;x2=intnx(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'DTMINUTE'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,x,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 11:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101170#M28399</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-08-08T11:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101171#M28400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is fantastic data_null.&amp;nbsp; I didn't realisze that you could use the DT prefix with time intervals.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 23:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101171#M28400</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-08-08T23:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datatime variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101172#M28401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note: You CAN use a DT prefix with datetime or time intervals but you don't have to for SECOND, MINUTE and HOUR. You do have to use the DT prefix for DAY and longer intervals (i.e. DTMONTH) to tell them apart from date intervals. Of course, you do have to use the corresponding date or datetime values for the other arguments. SAS (as of 9.3 at least) doesn't check for proper correspondence.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 02:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-datatime-variables/m-p/101172#M28401</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-08-09T02:18:57Z</dc:date>
    </item>
  </channel>
</rss>

