<?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 date time format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296019#M61941</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I encountered a time format: dd/mm/yy hhmm, like: 16/01/15 1030.&lt;/P&gt;&lt;P&gt;The format for it now is character $15. I want to put it to numerical. I tried:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;DT_TM = input(DateTime, &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;anydtdtm40.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;but it doesn't work, is anyone know what format this is? and how to put it to numerical value?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thank you!!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Best wishes.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Sep 2016 00:20:39 GMT</pubDate>
    <dc:creator>Xiaoningdemao</dc:creator>
    <dc:date>2016-09-02T00:20:39Z</dc:date>
    <item>
      <title>date time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296019#M61941</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I encountered a time format: dd/mm/yy hhmm, like: 16/01/15 1030.&lt;/P&gt;&lt;P&gt;The format for it now is character $15. I want to put it to numerical. I tried:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;DT_TM = input(DateTime, &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;anydtdtm40.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;but it doesn't work, is anyone know what format this is? and how to put it to numerical value?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thank you!!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Best wishes.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 00:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296019#M61941</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-09-02T00:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: date time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296037#M61942</link>
      <description>&lt;P&gt;No informat will read these datetime values directly. You can either&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) Read them as two separate fields and assemble them with DHMS()&lt;/P&gt;
&lt;P&gt;2) Extract the two fields, convert them to date and time and assemble them with dhms()&lt;/P&gt;
&lt;P&gt;3) Add a colon in the time field and read with informat anydtdtm.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options 2 and 3 are illustrated in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
DateTime = "16/01/15 1030";
dt = input(scan(DateTime,1," "), ddmmyy8.);
tm = input(scan(DateTime,2," "), hhmmss4.);
DT_TM1 = dhms(dt, hour(tm), minute(tm), second(tm));
DT_TM2 = input(prxChange("s#(\s*\d\d/\d\d/\d\d\s+\d\d)(.+)#\1:\2#o",1,DateTime), anydtdtm.);
format DT_TM1 DT_TM2 datetime17.;
put _all_;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Sep 2016 03:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296037#M61942</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-02T03:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: date time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296038#M61943</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dt_val $15. ;
datalines;
16/01/15 1030
06/01/15 1230
;

data want;
format dt datetime20.;
set have;
dt=dhms(input(substr(dt_val,1,8),ddmmyy8.),input(substr(dt_val,10,2),$2.),input(substr(dt_val,12,2),$2.),0);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It is not the best solution, you can use until someone suggest the correct informat to read.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 03:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296038#M61943</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-09-02T03:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: date time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296142#M61974</link>
      <description>&lt;P&gt;A big part of the issue is that values like&lt;/P&gt;
&lt;P&gt;16/01/15&lt;/P&gt;
&lt;P&gt;Could be 16 January 2015 (or 1915) or 15 January 2016 (or 1916). And if you get down to something like 06/01/15 you get to consider the possibility of 01 June 2015 (1915).&lt;/P&gt;
&lt;P&gt;Personally I think&amp;nbsp;anyone, yes including the US government, should be flogged with wet spaghetti noodles for using two-digit years in this day and age.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the SAS format guessers will give up on some values. And it is very likely the 06/01/15 gets the June interpretation which is very bad if it should be the January 2016.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that there is an option in SAS on how to treat two-digit years with the YEARCUTOFF option. The current default is 1920 which means year 20 is 1920. See any potential problem popping up in a couple years? Projection dates into 2020 will get treated as 1920 if they are read into SAS with two-digit years and throw the heck off models in SAS&amp;nbsp;for a bit.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 15:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296142#M61974</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-02T15:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: date time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296160#M61983</link>
      <description>Dear PG,&lt;BR /&gt;&lt;BR /&gt;Thank you for your solution! I accept RahulG's because her/his solution fits my data structure better.&lt;BR /&gt;&lt;BR /&gt;Thank you all the same~&lt;BR /&gt;&lt;BR /&gt;Best wishes.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2016 17:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296160#M61983</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-09-02T17:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: date time format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296161#M61984</link>
      <description>Dear RahulG,&lt;BR /&gt;&lt;BR /&gt;Thank you! I think this is what I'm looking for!&lt;BR /&gt;&lt;BR /&gt;Best wishes,&lt;BR /&gt;&lt;BR /&gt;Yuan</description>
      <pubDate>Fri, 02 Sep 2016 17:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-time-format/m-p/296161#M61984</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-09-02T17:03:34Z</dc:date>
    </item>
  </channel>
</rss>

