<?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 Working with datetime and milliseconds in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451428#M113797</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know what function can i use to work with datetime and milliseconds. I know that not exist function milliseconds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to put in a datastep using the macro but with not result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.FILTER_FOR_SORTSORTED;
  infile datalines dsd truncover;
  input Rtu date:DATETIME. Rtu ms:BEST12.;
  format Rtu date DATETIME. Rtu ms BEST12.;
datalines4;
,,,
,,,
,,,
,,,
,,,
,,,
,,,
;;;;


What i have

Datetime                  Milliseconds
23OCT17:19:55:29	620
23OCT17:19:17:53	500
04OCT17:15:55:52	800
18OCT17:14:11:32	470
28OCT17:15:33:29	160
23OCT17:09:13:40	130
18OCT17:15:13:02	100&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Datetime have datetime format and milliseconds a numeric format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want is a result like this: 18OCT17:15:13:02:100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw in other topic to this in datetime23.3 as format. I try to sum but with no result, and the function dhms( or other function)&amp;nbsp;hasn't milliseconds part. Or i have to change format to string, use function cats or catx, and again to datetime23.3 format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other question: Can i calculate time intervals with datetime23.3 formats like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18OCT17:15:13:02:100&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; 18OCT17:15:13:02:000&amp;nbsp;&amp;nbsp; = 100&amp;nbsp;&amp;nbsp; OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18OCT17:15:13:02:100&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; 18OCT17:15:13:01:000&amp;nbsp;&amp;nbsp; = 1:100 OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18OCT17:15:13:02:100&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; 18OCT17:15:12:02:100&amp;nbsp;&amp;nbsp; =1:0:000 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Aleixo&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 09:20:39 GMT</pubDate>
    <dc:creator>Aleixo</dc:creator>
    <dc:date>2018-04-05T09:20:39Z</dc:date>
    <item>
      <title>Working with datetime and milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451428#M113797</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know what function can i use to work with datetime and milliseconds. I know that not exist function milliseconds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to put in a datastep using the macro but with not result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.FILTER_FOR_SORTSORTED;
  infile datalines dsd truncover;
  input Rtu date:DATETIME. Rtu ms:BEST12.;
  format Rtu date DATETIME. Rtu ms BEST12.;
datalines4;
,,,
,,,
,,,
,,,
,,,
,,,
,,,
;;;;


What i have

Datetime                  Milliseconds
23OCT17:19:55:29	620
23OCT17:19:17:53	500
04OCT17:15:55:52	800
18OCT17:14:11:32	470
28OCT17:15:33:29	160
23OCT17:09:13:40	130
18OCT17:15:13:02	100&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Datetime have datetime format and milliseconds a numeric format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want is a result like this: 18OCT17:15:13:02:100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw in other topic to this in datetime23.3 as format. I try to sum but with no result, and the function dhms( or other function)&amp;nbsp;hasn't milliseconds part. Or i have to change format to string, use function cats or catx, and again to datetime23.3 format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other question: Can i calculate time intervals with datetime23.3 formats like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18OCT17:15:13:02:100&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; 18OCT17:15:13:02:000&amp;nbsp;&amp;nbsp; = 100&amp;nbsp;&amp;nbsp; OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18OCT17:15:13:02:100&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; 18OCT17:15:13:01:000&amp;nbsp;&amp;nbsp; = 1:100 OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18OCT17:15:13:02:100&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp; 18OCT17:15:12:02:100&amp;nbsp;&amp;nbsp; =1:0:000 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Aleixo&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 09:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451428#M113797</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T09:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Working with datetime and milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451435#M113802</link>
      <description>&lt;P&gt;Change the DATETIME.&amp;nbsp; format into DATETIME23. format then you can decide&lt;/P&gt;
&lt;P&gt;how many milisconds you prefer and change the 23 to 22 / 21 etc.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451435#M113802</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-05T10:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Working with datetime and milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451440#M113805</link>
      <description>&lt;P&gt;when i change to datetime23. SAS put milliseconds to 000. And Now how i can put my variable milliseconds into the variable datetime23.?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data_completa;
set data;
time_want=dhms(DATEPART(Datetime), HOUR(Datetime), MINUTE(Datetime), date(Datetime));
time_char=cats(put(time_want, datetime23.),':',Milliseconds);
format time_want datetime16. &lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But now i have a char with 18OCT17:15:13:02:100 and SAS does not admit a format datetime23.3 to time_char. The idea is time_char a variable type datetime23.3 or in this case datetime20.3 for example -&amp;gt;&amp;nbsp;30OCT17:04:20:03:100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleixo&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451440#M113805</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-04-05T10:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Working with datetime and milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451445#M113810</link>
      <description>&lt;P&gt;Datetime values are counts of seconds, a millisecond is the 1000th part of a second, so you have to divide your milliseconds by 1000 and add them to the datetime:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.FILTER_FOR_SORTSORTED;
  infile datalines truncover;
  input Rtu_date:DATETIME16. Rtu_ms:BEST12.;
  format Rtu_date DATETIME23.3 Rtu_ms BEST12.;
  Rtu_date = Rtu_date + Rtu_ms / 1000;
datalines4;
23OCT17:19:55:29 620
23OCT17:19:17:53 500
04OCT17:15:55:52 800
18OCT17:14:11:32 470
28OCT17:15:33:29 160
23OCT17:09:13:40 130
18OCT17:15:13:02 100
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451445#M113810</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T10:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Working with datetime and milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451474#M113833</link>
      <description>&lt;P&gt;Not sure what you want to achieve, but fractions of seconds is stored physically as decimals in the numerical variable.&lt;/P&gt;
&lt;P&gt;So yes, you can do subtraction between datetime variables. You could given your examples use time12.3 or any other preferred time format for better display.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 12:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-datetime-and-milliseconds/m-p/451474#M113833</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-04-05T12:05:43Z</dc:date>
    </item>
  </channel>
</rss>

