<?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: Converting an OLE OADate format variable to a SAS datetime format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565929#M11276</link>
    <description>&lt;P&gt;Thanks Reeza but something is still not going right.&amp;nbsp; This is what I have - The number of days between 1889 and 1960 is 25567.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;offset = 25567 - mdy(12, 30, 1889);&lt;BR /&gt;180 ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test; set ct.sample;&lt;BR /&gt;triageb = dhms(int(triagebegan) + offset, 0,0, triagebegan-int(triagebegan)*24*60*60);&lt;BR /&gt;36 format triageb datetime22.; run;&lt;/P&gt;&lt;P&gt;NOTE: Variable offset is uninitialized.&lt;BR /&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;53 at 35:11 53 at 35:33&lt;BR /&gt;NOTE: There were 53 observations read from the data set CT.SAMPLE.&lt;BR /&gt;NOTE: The data set WORK.TEST has 53 observations and 9 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.15 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2019 16:59:50 GMT</pubDate>
    <dc:creator>epiala1</dc:creator>
    <dc:date>2019-06-13T16:59:50Z</dc:date>
    <item>
      <title>Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565609#M11216</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a secondary dataset that has datetimes stored in OADate format.&amp;nbsp; I would like to reformat these variables into a SAS datetime format.&amp;nbsp; I am working with SAS 9.4.&amp;nbsp; Is there a way to easily do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Liz&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 16:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565609#M11216</guid>
      <dc:creator>epiala1</dc:creator>
      <dc:date>2019-06-12T16:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565611#M11217</link>
      <description>What is an OADAte format? What does it look like and what is the type and format applied currently to that variable?</description>
      <pubDate>Wed, 12 Jun 2019 16:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565611#M11217</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-12T16:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565615#M11218</link>
      <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The OADate is an OLE automation date that is a floating-point number whose integral component is the number of days before or after midnight, 30 December 1889 and whose fractional component represents the time on that day divided by 24.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my dataset the OADate is a BEST12. numeric value in the form xxxxx.yyyyyy where a value of say 42634.000000 is 09/21/2016 at 00:00:00. &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 16:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565615#M11218</guid>
      <dc:creator>epiala1</dc:creator>
      <dc:date>2019-06-12T16:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565625#M11221</link>
      <description>&lt;P&gt;Ok, so SAS stores dates as number of days and datetimes as number of seconds using a base year of January 1, 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you can do the following to get what you need - testing it of course:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Figure out the number of days between January 1 1960 and December 30, 1889&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Add that to the integer portion of your number to get the date&lt;/P&gt;
&lt;P&gt;3. For the 'time' component, take the decimal and mulitply by the number of seconds in a day (24hrs*60mins*60 secs) to get the number of seconds.&lt;/P&gt;
&lt;P&gt;4. Use DHMS() to convert that to a date time value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;offset = 0 - mdy(12, 30, 1889);

date_want = dhms(int(oadate) + offset, 0, 0, oadate-int(oadate)*24*60*60);

format date_want datetime22.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could try reading it in as a datetime and then using INTCK() and incrementing it by the offset as well. Not sure if that would work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277676"&gt;@epiala1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The OADate is an OLE automation date that is a floating-point number whose integral component is the number of days before or after midnight, 30 December 1889 and whose fractional component represents the time on that day divided by 24.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my dataset the OADate is a BEST12. numeric value in the form xxxxx.yyyyyy where a value of say 42634.000000 is 09/21/2016 at 00:00:00. &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 17:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565625#M11221</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-12T17:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565929#M11276</link>
      <description>&lt;P&gt;Thanks Reeza but something is still not going right.&amp;nbsp; This is what I have - The number of days between 1889 and 1960 is 25567.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;offset = 25567 - mdy(12, 30, 1889);&lt;BR /&gt;180 ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test; set ct.sample;&lt;BR /&gt;triageb = dhms(int(triagebegan) + offset, 0,0, triagebegan-int(triagebegan)*24*60*60);&lt;BR /&gt;36 format triageb datetime22.; run;&lt;/P&gt;&lt;P&gt;NOTE: Variable offset is uninitialized.&lt;BR /&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;53 at 35:11 53 at 35:33&lt;BR /&gt;NOTE: There were 53 observations read from the data set CT.SAMPLE.&lt;BR /&gt;NOTE: The data set WORK.TEST has 53 observations and 9 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.15 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565929#M11276</guid>
      <dc:creator>epiala1</dc:creator>
      <dc:date>2019-06-13T16:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565940#M11279</link>
      <description>Looks your offset line isn't in the data step?&lt;BR /&gt;Move that line to after your set statement and before you try and use it.</description>
      <pubDate>Thu, 13 Jun 2019 17:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565940#M11279</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T17:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565976#M11282</link>
      <description>&lt;P&gt;Yes, that removed the errors but I am still missing something.&amp;nbsp; I apologize!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;data test; set ct.sample;&lt;BR /&gt;offset = 0 - mdy(12,30,1889);&lt;BR /&gt;triageb = dhms(int(triagebegan) + offset, 25567, 0, triagebegan-int(triagebegan)*24*60*60);&lt;/P&gt;&lt;P&gt;format triageb datetime22.; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something is not working in the third line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the code my value becomes 02Dec2022 and all the times are the same.&lt;/P&gt;&lt;P&gt;As an example:&lt;/P&gt;&lt;P&gt;43615.576082 = 02Dec2022:03:06:56&lt;/P&gt;&lt;P&gt;43615.583186 = 02Dec2022:03:06:56&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Liz&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 19:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565976#M11282</guid>
      <dc:creator>epiala1</dc:creator>
      <dc:date>2019-06-13T19:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565988#M11283</link>
      <description>&lt;P&gt;Sorry, we both made mistakes &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure where you got the second parameter for the DHMS function, that should be 0.&lt;/P&gt;
&lt;PRE&gt;triageb = dhms(int(triagebegan) + offset, &lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;25567&lt;/STRONG&gt;&lt;/FONT&gt;, 0, triagebegan-int(triagebegan)*24*60*60);&lt;/PRE&gt;
&lt;P&gt;Second portion - needs to be in brackets to get the decimal portion otherwise order of operations is wrong:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;triageb = dhms(int(triagebegan) + offset, 25567, 0, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/FONT&gt;triagebegan-int(triagebegan)&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;*24*60*60);&lt;/PRE&gt;
&lt;P&gt;Changing things around a bit more this seems to work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*make fake data;
data have;
	triagebegan=42634.000000;
	output;
	triagebegan=43615.576082;
	output;

data test;
	set have;
	triageb=dhms(int(triagebegan) + mdy(12, 30, 1889)-1, 0, 0, 
		(triagebegan-int(triagebegan))*24*60*60);
	format triageb datetime22.;
run;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 19:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/565988#M11283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T19:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Converting an OLE OADate format variable to a SAS datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/566008#M11285</link>
      <description>&lt;P&gt;Oh, I can't thank you enough. It worked beautifully!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again Reeza!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Liz&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 19:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-an-OLE-OADate-format-variable-to-a-SAS-datetime/m-p/566008#M11285</guid>
      <dc:creator>epiala1</dc:creator>
      <dc:date>2019-06-13T19:56:04Z</dc:date>
    </item>
  </channel>
</rss>

