<?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: Apply decimals to SAS datetime picture format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787824#M251805</link>
    <description>by jove - that does it!  &lt;BR /&gt;&lt;BR /&gt;Thanks, I missed the default option somehow!</description>
    <pubDate>Thu, 30 Dec 2021 17:41:14 GMT</pubDate>
    <dc:creator>AllanBowe</dc:creator>
    <dc:date>2021-12-30T17:41:14Z</dc:date>
    <item>
      <title>Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787778#M251776</link>
      <description>&lt;P&gt;I'm trying to add decimals (all of them) to my picture format.&amp;nbsp; This is what I have so far (using the new&lt;A href="https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787778#M251776" target="_self"&gt;&amp;nbsp;little "s"&lt;/A&gt; for milliseconds):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  PROC FORMAT;
    picture yymmddThhmmss other='%0Y-%0m-%0d %0H:%0M:%0s' (datatype=datetime);
  RUN;
  
  data _null_;
   x=datetime();
   put x= yymmddThhmmss.;
   put x= yymmddThhmmss.8;
   put x= best16.15;
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And this is the result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AllanBowe_0-1640872945115.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67020iDD64BD8B2E047AD4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AllanBowe_0-1640872945115.png" alt="AllanBowe_0-1640872945115.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some reason, the decimal part is ALWAYS rounded.&amp;nbsp; Does anyone have any ideas for displaying it fully, whilst being accurate both with / without the decimal part in the format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 14:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787778#M251776</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-12-30T14:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787781#M251778</link>
      <description>&lt;P&gt;I think I cracked it:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  PROC FORMAT;
    picture yymmddThhmmss other='%0Y-%0m-%0d %0H:%0M:%0s.0000' (datatype=datetime);
  RUN;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AllanBowe_0-1640873933711.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67021iC771EC56AD17D88F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AllanBowe_0-1640873933711.png" alt="AllanBowe_0-1640873933711.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 14:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787781#M251778</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-12-30T14:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787807#M251793</link>
      <description>&lt;P&gt;Hello Allan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Glad that you have sorted it out.&lt;/P&gt;
&lt;P&gt;(The decimals in your 2nd put statement were cut off by the way, nothing was rounded &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just this note :&lt;/P&gt;
&lt;P&gt;More than 5 decimals for the milliseconds (in a datetime value) is not useful. It's not trustworthy / reliable beyond 5.&lt;/P&gt;
&lt;P&gt;You cannot trust the '707' in :&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;x=2021-12-30 17:20:49.02856&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;707&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;With the&amp;nbsp;&lt;SPAN&gt;internal 64-bit floating-point representation you get about&amp;nbsp;15 significant digits.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I remember helping an econom(etri)ics student with her thesis on high-frequency trading on the stock market (I think it was NASDAQ).&lt;BR /&gt;Those milli-seconds and calculating with them was an ordeal and a challenge. &lt;BR /&gt;Eventually, I did that with a trick, but I don't remember the finer points (the subtleties). But it worked!&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But maybe you just want to display instead of doing calculations (?).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 16:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787807#M251793</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-30T16:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787816#M251798</link>
      <description>&lt;P&gt;Hi Koen - thanks for your inputs. That's a great point about 15 significant digits. Perhaps we will indeed need to restrict datetime decimals to 5dp. At this stage, very happy to have &amp;gt;0 dp!&lt;BR /&gt;&lt;BR /&gt;For our use case, all I'm looking to do is send the data from SAS to a web client, unaltered (as much as possible).&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 16:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787816#M251798</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-12-30T16:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787822#M251803</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you're using a different SAS version or platform because with my Windows SAS 9.4M5 I get an unwanted additional decimal point with your format:&lt;/P&gt;
&lt;PRE&gt;660  data _null_;
661   x=1956493090.20730710;
662   put x= yymmddThhmmss.;
663   put x= yymmddThhmmss.15;
664   put x= best16.;
665  run;

x=2021-12-30 14:18:10.0000
x=2021-12-30 14:18:10.207307&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;0
x=1956493090.20731&lt;/PRE&gt;
&lt;P&gt;I'd rather specify the &lt;EM&gt;length&lt;/EM&gt; of the format either in the definition or in the PUT statement:&lt;/P&gt;
&lt;PRE&gt;picture yymmddThhmmss &lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;(default=28)&lt;/FONT&gt;&lt;/STRONG&gt; other='%0Y-%0m-%0d %0H:%0M:%0s' (datatype=datetime);&lt;/PRE&gt;
&lt;P&gt;With that (or with other default lengths &amp;gt;=26) I obtain&lt;/P&gt;
&lt;PRE&gt;x=2021-12-30 14:18:10.207307&lt;/PRE&gt;
&lt;P&gt;from the second PUT statement.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 17:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787822#M251803</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-12-30T17:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787823#M251804</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's a good point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On my Windows SAS 9.4 M7&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;&amp;nbsp;'s last picture format is not working either (same phenomenon &lt;FONT color="#FF0000"&gt;.0&lt;/FONT&gt;)&lt;/P&gt;
&lt;P&gt;, but on my&amp;nbsp;&lt;SPAN&gt;Full Viya 3.5 LINA upgrade (21w13) (Linux OS) it is working!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I haven't tested VIYA 4 but I am sure it will work on VIYA 4 as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 17:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787823#M251804</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-12-30T17:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787824#M251805</link>
      <description>by jove - that does it!  &lt;BR /&gt;&lt;BR /&gt;Thanks, I missed the default option somehow!</description>
      <pubDate>Thu, 30 Dec 2021 17:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787824#M251805</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-12-30T17:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Apply decimals to SAS datetime picture format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787982#M251854</link>
      <description>&lt;P&gt;Freelance is right. You need make the length of format bigger .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;42    PROC FORMAT;
43       picture yymmddThhmmss other='%0Y-%0m-%0d %0H:%0M:%0s' (datatype=datetime);
NOTE: 输出格式 YYMMDDTHHMMSS 已输出。
44     RUN;

NOTE: “PROCEDURE FORMAT”所用时间（总处理时间）:
      实际时间          0.04 秒
      CPU 时间          0.01 秒


45
46     data _null_;
47      x=datetime();
48      put x= yymmddThhmmss.;
49      put x= yymmddThhmmss32.8;
50      put x= best16.15;
51     run;

x=2022-01-01 17:49:32
x=2022-01-01 17:49:31.52500009
x=1956678571.525
&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jan 2022 09:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-decimals-to-SAS-datetime-picture-format/m-p/787982#M251854</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-01T09:51:02Z</dc:date>
    </item>
  </channel>
</rss>

