<?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: convert numeric date to another format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707206#M217124</link>
    <description>&lt;P&gt;Your question is strangely worded so it is not clear what you are asking for.&amp;nbsp; In SAS a FORMAT is just instructions for how to display the values.&amp;nbsp; There are only two types of variables, fixed length character strings and floating point numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to display the DATETIME values in Y-M-D order then use the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=p0c419d4254oddn19koluiafrsel.htm&amp;amp;locale=en" target="_self"&gt;E8601DN10.&lt;/A&gt;&amp;nbsp;format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=data;
format want b8601dn10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to first convert the datetime values (number of seconds) to date values (number of days) then use the DATEPART() function.&amp;nbsp; Then for the newly created date values you can use either the YYMMDD10. format or the E8601DA10. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = datepart(data);
format want yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really wanted to create a character string then use the PUT() function with the appropriate format to convert the numeric values into strings.&lt;/P&gt;</description>
    <pubDate>Sat, 19 Dec 2020 21:36:41 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-12-19T21:36:41Z</dc:date>
    <item>
      <title>convert numeric date to another format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707137#M217110</link>
      <description>&lt;P&gt;I have a numeric date with time and I need to convert just the datepart into yyyy-mm-dd format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data (numeric):&lt;/P&gt;&lt;P&gt;16DEC2020:00:00:00.000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want (numeric):&lt;/P&gt;&lt;P&gt;2020-12-16&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 06:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707137#M217110</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2020-12-19T06:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: convert numeric date to another format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707138#M217111</link>
      <description>&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;dtm = '16DEC2020:00:00:00.000'dt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;date = datepart(dtm);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;putlog date yymmdd10.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 07:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707138#M217111</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-12-19T07:32:08Z</dc:date>
    </item>
    <item>
      <title>Betreff: convert numeric date to another format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707198#M217122</link>
      <description>&lt;P&gt;If you don't want to use the Macro Language:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; format data datetime20.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; data = "16dec2020:0:0:0"dt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; want = put(datepart(data), yymmdd10.);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 20:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707198#M217122</guid>
      <dc:creator>KlausBücher</dc:creator>
      <dc:date>2020-12-19T20:06:02Z</dc:date>
    </item>
    <item>
      <title>Betreff: convert numeric date to another format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707199#M217123</link>
      <description>&lt;P&gt;The difference between the two solutions above is that the method from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt; leaves the date as numeric, which then enables you to perform arithmetic and logical operations on it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40244"&gt;@KlausBücher&lt;/a&gt; creates a character string which looks like a date to humans, but SAS will never consider this a date and so you can't perform arithmetic or logical operations on it (well, actually you can perform character string logical operations on it).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;So I strongly recommend keeping the date numeric.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 21:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707199#M217123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-19T21:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: convert numeric date to another format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707206#M217124</link>
      <description>&lt;P&gt;Your question is strangely worded so it is not clear what you are asking for.&amp;nbsp; In SAS a FORMAT is just instructions for how to display the values.&amp;nbsp; There are only two types of variables, fixed length character strings and floating point numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to display the DATETIME values in Y-M-D order then use the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=p0c419d4254oddn19koluiafrsel.htm&amp;amp;locale=en" target="_self"&gt;E8601DN10.&lt;/A&gt;&amp;nbsp;format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=data;
format want b8601dn10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to first convert the datetime values (number of seconds) to date values (number of days) then use the DATEPART() function.&amp;nbsp; Then for the newly created date values you can use either the YYMMDD10. format or the E8601DA10. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = datepart(data);
format want yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really wanted to create a character string then use the PUT() function with the appropriate format to convert the numeric values into strings.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 21:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-numeric-date-to-another-format/m-p/707206#M217124</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-19T21:36:41Z</dc:date>
    </item>
  </channel>
</rss>

