<?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 Convert SAS date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897106#M354507</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reasons I can't seem to do this. How do I convert a date&lt;/P&gt;&lt;P&gt;DATE = '20231002' to&lt;/P&gt;&lt;P&gt;DATE_EXTRACTION&amp;nbsp; = '02OCT2023' in SAS please?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATE_EXTRACTION = put(datepart(DATE), date9.);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get 22AUG1960 instead of&amp;nbsp;02OCT2023&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 08:36:24 GMT</pubDate>
    <dc:creator>MILKYLOVE</dc:creator>
    <dc:date>2023-10-04T08:36:24Z</dc:date>
    <item>
      <title>Convert SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897106#M354507</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reasons I can't seem to do this. How do I convert a date&lt;/P&gt;&lt;P&gt;DATE = '20231002' to&lt;/P&gt;&lt;P&gt;DATE_EXTRACTION&amp;nbsp; = '02OCT2023' in SAS please?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATE_EXTRACTION = put(datepart(DATE), date9.);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I get 22AUG1960 instead of&amp;nbsp;02OCT2023&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 08:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897106#M354507</guid>
      <dc:creator>MILKYLOVE</dc:creator>
      <dc:date>2023-10-04T08:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897108#M354508</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   date = '20231002';
   new  = put(input(date, yymmdd8.), date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Oct 2023 09:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897108#M354508</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-10-04T09:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert SAS date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897118#M354512</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404650"&gt;@MILKYLOVE&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some reasons I can't seem to do this. How do I convert a date&lt;/P&gt;
&lt;P&gt;DATE = '20231002' to&lt;/P&gt;
&lt;P&gt;DATE_EXTRACTION&amp;nbsp; = '02OCT2023' in SAS please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATE_EXTRACTION = put(datepart(DATE), date9.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I get 22AUG1960 instead of&amp;nbsp;02OCT2023&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Dates should never be character strings, they should be numbers. Numbers that represent the number of days since 01JAN1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Had you written this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATE = '02OCT2023'd;
format date date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you would have the correct date ... this is the way to translate dates that you understand to numerical SAS dates. Also please note that this will not work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATE = '20231002'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, when you have actual SAS dates, you do NOT need the DATEPART function; the only time you need the DATEPART function is when the value is SAS date/time values. But your value is a SAS date, not a date/time value, and DATEPART will not do meaningful things to date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 10:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-SAS-date/m-p/897118#M354512</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-04T10:17:33Z</dc:date>
    </item>
  </channel>
</rss>

