<?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 date time conversion to numeric date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231307#M42060</link>
    <description>A single variable cannot be date, numeric, character at the same time. The usual solution in such a situation is to keep it in a character field.</description>
    <pubDate>Fri, 23 Oct 2015 07:22:41 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-10-23T07:22:41Z</dc:date>
    <item>
      <title>Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231304#M42058</link>
      <description>&lt;P&gt;I have a problem with a 'Date'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a date value in this format DDMMMYYYY:00:00:00. Now, during some operation, it gets converted to a number (10 digit) while sending it to a character field with some other numeric and character values. I would like to convert it back to a date value, else it does not make sense for presentation purpose.&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;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;x=input(strip(value), datetime18.);&lt;/P&gt;
&lt;P&gt;format x Date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does not work. Also, will be possible to keep the date at the same character field, after the conversion? &amp;nbsp;Reason is, the character field is supposed to hold the values of multiple character, numeric and date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 06:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231304#M42058</guid>
      <dc:creator>zoomzoom</dc:creator>
      <dc:date>2015-10-23T06:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231305#M42059</link>
      <description>&lt;P&gt;Not understand how and why you do the&amp;nbsp;different conversions.&lt;/P&gt;&lt;P&gt;But the best would be to store the value as a SAS date (dateime) value, then you can use formats to display it almost in any format that you like, without&amp;nbsp;having to do conversions.&lt;/P&gt;&lt;P&gt;Assuming that you have 0:00:00 as a time in your example, this is really a date value, right?&lt;/P&gt;&lt;P&gt;The simplest is to do a substr() and input() using date9. informat.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 06:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231305#M42059</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-10-23T06:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231307#M42060</link>
      <description>A single variable cannot be date, numeric, character at the same time. The usual solution in such a situation is to keep it in a character field.</description>
      <pubDate>Fri, 23 Oct 2015 07:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231307#M42060</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-10-23T07:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231310#M42061</link>
      <description>&lt;P&gt;I think that your datetime variable is SA datetime variable if it is ten digit long number, number of seconds after 01JAN1960 00:00. You just have to use proper format to display it. You can take the day out with datepart function as separate variable.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 07:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231310#M42061</guid>
      <dc:creator>AskoLötjönen</dc:creator>
      <dc:date>2015-10-23T07:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231313#M42063</link>
      <description>&lt;P&gt;Out of interest, is there a reason that you do not use ISO dates, i.e. YYYYMMDDTHH:MM:SS...? &amp;nbsp;I would have thought that would be better for a text field and more standard. &amp;nbsp;It can then be used with the E8601 format, and you can keep date, time, or datetime as a numeric field. &amp;nbsp;This is what we do in my industry, numeric date, time, and character ISO date.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 08:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231313#M42063</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-23T08:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231344#M42074</link>
      <description>The dates came from oracle. I'm calculating maximum value for a list of character, numeric and date variables. And I send all the maximum values to a field called max_value, after transposing them. I use _numeric_ to get all the numeric values and date gets converted to a number in the max value field. As I said, now I need to convert it to some form of readable date, and keep it/push it inside the same max value column. The date from oracle came in this form: 18FEB2010:00:00:00</description>
      <pubDate>Fri, 23 Oct 2015 13:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231344#M42074</guid>
      <dc:creator>zoomzoom</dc:creator>
      <dc:date>2015-10-23T13:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231346#M42075</link>
      <description>&lt;P&gt;Lets backtrack a bit, the post doesn't make much sense, you can't take a max of character data. &amp;nbsp;Perhaps start by posting some example test data (a couple of obs) in the form of a datastep, and what you want the output to look like.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 13:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231346#M42075</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-23T13:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Character date time conversion to numeric date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231356#M42076</link>
      <description>&lt;P&gt;Here's some code that gets you back and forth between char and date formats:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;format date datetime18.;&lt;BR /&gt;date = '23OCT2015:10:40:30'dt;&lt;BR /&gt;date_char = input(put(date,datetime18.),$18.);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have(keep=date_char);&lt;BR /&gt;format date date9.;&lt;BR /&gt;date = input(put(date_char,$18.),date9.);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 14:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-date-time-conversion-to-numeric-date/m-p/231356#M42076</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-10-23T14:41:12Z</dc:date>
    </item>
  </channel>
</rss>

