<?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: How to leave a leading 0 in a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874500#M345524</link>
    <description>&lt;P&gt;Why are you bothering to create a character value for that value? It won't sort properly and can't be used an form of calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a custom format to display the existing value with a different appearance:&lt;/P&gt;
&lt;PRE&gt;proc format;
picture mydatetime
low-high ='%0d/%0m/%Y %0H:%0M' (datatype=datetime);
run;

data example;
   x='07May2023:09:12:01'dt;
   format x mydatetime.;
run;&lt;/PRE&gt;
&lt;P&gt;This is one place that you really want to use single quotes to prevent confusion with the macro processor and the format directives. The CASE of the letters in the directives for the date and time portions are critical.&lt;/P&gt;
&lt;P&gt;The / space and : are inserted in the relative positions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 May 2023 17:32:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-05-08T17:32:17Z</dc:date>
    <item>
      <title>How to leave a leading 0 in a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874494#M345521</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have a table called POLAIM_MERGE that includes the field LOAD_LAST_DATETIME (format=datetime20, informat=datetime20)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shlomiohana_1-1683565645171.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83698i7BA622A1D545AAFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shlomiohana_1-1683565645171.png" alt="shlomiohana_1-1683565645171.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data POLAIM_ADD_FORMAT;
     set POLAIM_MERGE;
     mydate =datepart(LOAD_LAST_DATETIME);
     mytime = timepart(LOAD_LAST_DATETIME);
     format mydate ddmmyy10. mytime time5.;
     LOAD_LAST_DATETIME_NEW= put(mydate,ddmmyy10.)||' '||put(mytime,time5.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wrote the following code but I get in the field "mytime" the time 9:03, I would like the leading 0 to be displayed at the time, desired display: 09:03 How do I change the code to show as I need?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shlomiohana_2-1683565767645.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83699i06528869C9903F9F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shlomiohana_2-1683565767645.png" alt="shlomiohana_2-1683565767645.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 17:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874494#M345521</guid>
      <dc:creator>shlomiohana</dc:creator>
      <dc:date>2023-05-08T17:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to leave a leading 0 in a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874496#M345522</link>
      <description>&lt;P&gt;The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/p06erle1ezuickn0zv2omg9xzxkh.htm" target="_self"&gt;TODw. format&lt;/A&gt; will write a leading 0.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data POLAIM_ADD_FORMAT;
     set POLAIM_MERGE;
     mydate =datepart(LOAD_LAST_DATETIME);
     mytime = timepart(LOAD_LAST_DATETIME);
     format mydate ddmmyy10. mytime tod5.;
     LOAD_LAST_DATETIME_NEW= put(mydate,ddmmyy10.)||' '||put(mytime,tod5.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 May 2023 17:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874496#M345522</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2023-05-08T17:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to leave a leading 0 in a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874497#M345523</link>
      <description>Why the character variable conversion? Would a custom format that remained datetime be useful as it would then sort correctly?</description>
      <pubDate>Mon, 08 May 2023 17:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874497#M345523</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-08T17:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to leave a leading 0 in a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874500#M345524</link>
      <description>&lt;P&gt;Why are you bothering to create a character value for that value? It won't sort properly and can't be used an form of calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a custom format to display the existing value with a different appearance:&lt;/P&gt;
&lt;PRE&gt;proc format;
picture mydatetime
low-high ='%0d/%0m/%Y %0H:%0M' (datatype=datetime);
run;

data example;
   x='07May2023:09:12:01'dt;
   format x mydatetime.;
run;&lt;/PRE&gt;
&lt;P&gt;This is one place that you really want to use single quotes to prevent confusion with the macro processor and the format directives. The CASE of the letters in the directives for the date and time portions are critical.&lt;/P&gt;
&lt;P&gt;The / space and : are inserted in the relative positions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 17:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-leave-a-leading-0-in-a-date/m-p/874500#M345524</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-08T17:32:17Z</dc:date>
    </item>
  </channel>
</rss>

