<?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 SAS datetime in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724644#M35142</link>
    <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;I am a new SAS user.&lt;/P&gt;&lt;P&gt;I have a character DATETIME variable named "run_date" recorded as "YYYY-MM-DD HH:MM" which has a 17 character length. (2018-OCT-11 09:15).&lt;/P&gt;&lt;P&gt;I want to convert into numeric datetime variable in date19 format.&lt;/P&gt;&lt;P&gt;Hope you can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Yuba&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Mar 2021 20:39:35 GMT</pubDate>
    <dc:creator>yubaraj</dc:creator>
    <dc:date>2021-03-08T20:39:35Z</dc:date>
    <item>
      <title>SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724644#M35142</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;I am a new SAS user.&lt;/P&gt;&lt;P&gt;I have a character DATETIME variable named "run_date" recorded as "YYYY-MM-DD HH:MM" which has a 17 character length. (2018-OCT-11 09:15).&lt;/P&gt;&lt;P&gt;I want to convert into numeric datetime variable in date19 format.&lt;/P&gt;&lt;P&gt;Hope you can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Yuba&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 20:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724644#M35142</guid>
      <dc:creator>yubaraj</dc:creator>
      <dc:date>2021-03-08T20:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724651#M35143</link>
      <description>Something like the following should work - ANYDTDTM will automatically detect your datetime informat. &lt;BR /&gt;&lt;BR /&gt;run_date_num = input(run_date, anydtdtm.);&lt;BR /&gt;format run_date_num datetime.;&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Mar 2021 20:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724651#M35143</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-08T20:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724667#M35144</link>
      <description>&lt;P&gt;Hi Reeza&lt;/P&gt;&lt;P&gt;Thanks a lot for your quick response.&lt;/P&gt;&lt;P&gt;The program you suggested runs perfectly with no error message on the log window. but the output data has all the 'run_date_num' as blank.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The original variable was in&amp;nbsp; Character format $17 and informat$17 and not all observations have a 'run date' data.&lt;/P&gt;&lt;P&gt;This is surprising, any idea what could be the reason.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Yuba&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 21:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724667#M35144</guid>
      <dc:creator>yubaraj</dc:creator>
      <dc:date>2021-03-08T21:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724674#M35145</link>
      <description>&lt;P&gt;Show your code and log please. Could be anything from a missing semicolon to a different format for you date than shown in your question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/218503"&gt;@yubaraj&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Reeza&lt;/P&gt;
&lt;P&gt;Thanks a lot for your quick response.&lt;/P&gt;
&lt;P&gt;The program you suggested runs perfectly with no error message on the log window. but the output data has all the 'run_date_num' as blank.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original variable was in&amp;nbsp; Character format $17 and informat$17 and not all observations have a 'run date' data.&lt;/P&gt;
&lt;P&gt;This is surprising, any idea what could be the reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Yuba&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 22:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724674#M35145</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-08T22:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724679#M35146</link>
      <description>&lt;P&gt;NVM - its because you have a very unique data format and you'll need a specific informat for it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;"YYYY-MM-DD HH:MM" =&amp;gt; this is a standard format and my methods works in this case&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2018-OCT-11 09:15 =&amp;gt; this is a non-standard format and my method does not work in this case.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My apologies, I didn't notice the discrepancy between these initially. See below.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
date_have = "2018-OCT-11 09:15";
date_want = input(date_have, anydtdtm.);
output;
date_have = "2018-10-11 09:15";
date_want = input(date_have, anydtdtm.);
output;
format date_want datetime.;
run;

proc print data=example;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Mar 2021 22:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724679#M35146</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-08T22:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724682#M35147</link>
      <description>&lt;P&gt;There is not such thing as a DATE19. format DATE formats run from 5 to 11.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would want a DATETIME format to display the time component.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Congratulations for finding one of the sillier date time formats:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
  x="2018-OCT-11 09:15";
  y = dhms(input(x,anydtdte11.),0,0,input(substr(x,13),time.));
  format y datetime19.;
run;&lt;/PRE&gt;
&lt;P&gt;Which uses a specific length&amp;nbsp; to read the date part from the first 11 characters and the time from the last 5.&lt;/P&gt;
&lt;P&gt;If your "dates" don't have 2-digit values for the day this will likely fail.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 22:19:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724682#M35147</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-08T22:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS datetime</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724720#M35153</link>
      <description>Great Thanks ballardw , that worked perfectly. Thanks Reeza.</description>
      <pubDate>Tue, 09 Mar 2021 00:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/SAS-datetime/m-p/724720#M35153</guid>
      <dc:creator>yubaraj</dc:creator>
      <dc:date>2021-03-09T00:29:10Z</dc:date>
    </item>
  </channel>
</rss>

