<?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: Character to SAS Date conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94315#M19867</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DTDATE9. format display DDMMMYYYY when applied to a datetime variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Feb 2013 16:05:35 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2013-02-01T16:05:35Z</dc:date>
    <item>
      <title>Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94311#M19863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello members,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a new member joined. I know the question I'm going to ask might have been asked n number of times. But so far I'm unable to fix the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to convert SAS Date in DHMS format to SAS Date Date9 format. The date came in from SQL server and in DDMMMYYYY:00:00:00.000 format.&lt;/P&gt;&lt;P&gt;The date I have is 10JAN2011. I have converted to numeric and to character and I get the value 18637 in character format. But then, I'm unable to convert to date9 format. All I get is missing values with error message as "Invalid argument to function Input". I also tried with sasdatefmt in standard syntax, but the code is not working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code :&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dt= input(put(datepart(Date),5.),ddmmyy10.);&lt;/P&gt;&lt;P&gt;format dt Date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 15:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94311#M19863</guid>
      <dc:creator>zoomzoom</dc:creator>
      <dc:date>2013-02-01T15:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94312#M19864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;18637 is 10Jan2011 nothing else to do except associate a format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 18637;&lt;/P&gt;&lt;P&gt;19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put x=date9.;&lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x=10JAN2011&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 15:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94312#M19864</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-02-01T15:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94313#M19865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have modified the code to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set have;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; dt= put(datepart(Date),5.);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;format dt date9.;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;But the error exits. The log says:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;"Note 484-185: Format $Date was not found or could not be loaded".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 15:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94313#M19865</guid>
      <dc:creator>zoomzoom</dc:creator>
      <dc:date>2013-02-01T15:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94314#M19866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure its clear what you are trying to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all you need is the date to show as 10Jan2011 then you do not need to use the put function (just the datepart) and just associate the format with the variable. If you are converting to a character variable then I think you need to just replace the 5. format in the put with the date9. format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;Sample code to illustrate&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x = 18637;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format x date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x2= put(x,date9.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y='10Jan2011 12:00:00'dt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y2 = datepart(y);&lt;/P&gt;&lt;P&gt;&amp;nbsp; format y2 date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y3 = put(y2,date9.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 16:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94314#M19866</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-02-01T16:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94315#M19867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DTDATE9. format display DDMMMYYYY when applied to a datetime variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 16:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94315#M19867</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-01T16:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94316#M19868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, esjackso1. That was right, the code is working fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 16:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94316#M19868</guid>
      <dc:creator>zoomzoom</dc:creator>
      <dc:date>2013-02-01T16:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94317#M19869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The date I have is 10JAN2011. I have converted to numeric and to character and I get the value 18637 in character format.&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do NOT convert to character.&amp;nbsp; When you get the NUMBER 18637 you are done.&amp;nbsp; All you need after that is to associate a date format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: data _null_&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 16:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94317#M19869</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-02-01T16:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Character to SAS Date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94318#M19870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, DBailey. Your answer works just fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 16:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-SAS-Date-conversion/m-p/94318#M19870</guid>
      <dc:creator>zoomzoom</dc:creator>
      <dc:date>2013-02-01T16:08:07Z</dc:date>
    </item>
  </channel>
</rss>

