<?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: Change DATETIME22.3 to mmddyy10. ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/939001#M368767</link>
    <description>&lt;P&gt;If you want to use a DATETIME value show a date type appearance SAS did not provide then roll your own format. Proc Format has a bunch of directives to use with the PICTURE statement to show just about any element of a date, time or datetime value you may reasonably want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This example creates a DT_mmddyy format analogous to the SAS supplied DTDATE format.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture dt_mmddyy (default=10)
   low-high = '%0m/%0d/%Y'   (datatype=datetime);
run;

data example;
   x=dhms(today(),0,0,time());
   format x dt_mmddyy.;
run;&lt;/PRE&gt;
&lt;P&gt;Note that picture statements are one place that you pretty much need to use the single quotes otherwise the directives will be treated as macro references and cause errors.&lt;/P&gt;
&lt;P&gt;You did not specify that the month and day should be preceded by zero when single digits. To closer appear like MMDDYY10 I used the 0s. The / and other characters would be literals. So if you want 10-12-2023 (dashes between bits) use the - character in the directive list. Or a space, comma, decimal or drive people nuts with ^ or &amp;lt; as separators.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Aug 2024 17:48:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-08-12T17:48:04Z</dc:date>
    <item>
      <title>Change DATETIME22.3 to mmddyy10. ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/938993#M368761</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me to change the numeric format,&amp;nbsp;DATETIME22.3 (12JAN2023:18:05:44.700) to mmddyy10 (10/12/2023).&amp;nbsp; &amp;nbsp;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 17:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/938993#M368761</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-08-12T17:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATETIME22.3 to mmddyy10. ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/938996#M368764</link>
      <description>&lt;P&gt;Your variable that is formatted as DATETIME22.3 is a Date/Time variable, which is internally the number of second between midnight at the start of 01JAN1960. If you want it as MMDDYY10, this would have to be a Date variable which is internally the number of days since 01JAN1960. You cannot use a Date/Time variable. So you need to create a new variable that is Date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    newvariable=datepart(oldvariable);
    format newvariable mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: If you don't insist on mmddyy10, but could live with a date formatted as 01JAN1960, then you just need to assign the DTDATE9. format, you would not need to create a new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    format oldvariable dtdate9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or even better&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets library=work nolist;
    modify have;
    format oldvariable dtdate9.;
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Aug 2024 17:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/938996#M368764</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-12T17:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATETIME22.3 to mmddyy10. ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/939001#M368767</link>
      <description>&lt;P&gt;If you want to use a DATETIME value show a date type appearance SAS did not provide then roll your own format. Proc Format has a bunch of directives to use with the PICTURE statement to show just about any element of a date, time or datetime value you may reasonably want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This example creates a DT_mmddyy format analogous to the SAS supplied DTDATE format.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture dt_mmddyy (default=10)
   low-high = '%0m/%0d/%Y'   (datatype=datetime);
run;

data example;
   x=dhms(today(),0,0,time());
   format x dt_mmddyy.;
run;&lt;/PRE&gt;
&lt;P&gt;Note that picture statements are one place that you pretty much need to use the single quotes otherwise the directives will be treated as macro references and cause errors.&lt;/P&gt;
&lt;P&gt;You did not specify that the month and day should be preceded by zero when single digits. To closer appear like MMDDYY10 I used the 0s. The / and other characters would be literals. So if you want 10-12-2023 (dashes between bits) use the - character in the directive list. Or a space, comma, decimal or drive people nuts with ^ or &amp;lt; as separators.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 17:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-DATETIME22-3-to-mmddyy10/m-p/939001#M368767</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-12T17:48:04Z</dc:date>
    </item>
  </channel>
</rss>

