<?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 Extract date, hour, minute, second from  mm/dd/yyyy hh:mm:ss in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824198#M325460</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;When I import a CSV file into SAS, the column datetime having format&amp;nbsp;mm/dd/yyyy hh:mm:ss is imported and in SAS it has:&lt;/P&gt;
&lt;P&gt;Length 8&lt;/P&gt;
&lt;P&gt;Format&amp;nbsp;DATETIME16.&lt;/P&gt;
&lt;P&gt;Informat&amp;nbsp;ANYDTDTM40.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the below code to extract year month date and SAS give errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data intra; set intra;
year=year(datetime);
month=month(datetime);

hour=hour(datetime);
minute=minute(datetime);
second=second(datetime);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: Invalid argument to function &lt;STRONG&gt;YEAR(1973854021.9)&lt;/STRONG&gt; at line 218 column 6.&lt;BR /&gt;NOTE: Invalid argument to function &lt;STRONG&gt;MONTH(1973854021.9)&lt;/STRONG&gt; at line 219 column 7.&lt;BR /&gt;_0=A _1=117.871 _2=479962 datetime=19JUL22:12:47:02 year=. month=. hour=12 minute=47&lt;BR /&gt;second=1.8895449638 date=. _ERROR_=1 _N_=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me with that?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2022 17:08:47 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2022-07-19T17:08:47Z</dc:date>
    <item>
      <title>Extract date, hour, minute, second from  mm/dd/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824198#M325460</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;When I import a CSV file into SAS, the column datetime having format&amp;nbsp;mm/dd/yyyy hh:mm:ss is imported and in SAS it has:&lt;/P&gt;
&lt;P&gt;Length 8&lt;/P&gt;
&lt;P&gt;Format&amp;nbsp;DATETIME16.&lt;/P&gt;
&lt;P&gt;Informat&amp;nbsp;ANYDTDTM40.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the below code to extract year month date and SAS give errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data intra; set intra;
year=year(datetime);
month=month(datetime);

hour=hour(datetime);
minute=minute(datetime);
second=second(datetime);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: Invalid argument to function &lt;STRONG&gt;YEAR(1973854021.9)&lt;/STRONG&gt; at line 218 column 6.&lt;BR /&gt;NOTE: Invalid argument to function &lt;STRONG&gt;MONTH(1973854021.9)&lt;/STRONG&gt; at line 219 column 7.&lt;BR /&gt;_0=A _1=117.871 _2=479962 datetime=19JUL22:12:47:02 year=. month=. hour=12 minute=47&lt;BR /&gt;second=1.8895449638 date=. _ERROR_=1 _N_=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me with that?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 17:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824198#M325460</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-07-19T17:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date, hour, minute, second from  mm/dd/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824201#M325461</link>
      <description>&lt;P&gt;YEAR(),MONTH() and DAY() functions operate on DATE values (number of days)&lt;/P&gt;
&lt;P&gt;HOUR(),MINUTE() and SECOND() functions operate on either DATETIME or TIME values (number of seconds).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert a DATETIME value to DATE value use the DATEPART() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year(datepart(datetime))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2022 17:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824201#M325461</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-19T17:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extract date, hour, minute, second from  mm/dd/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824202#M325462</link>
      <description>&lt;P&gt;Thank you for your help, Tom.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 17:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-date-hour-minute-second-from-mm-dd-yyyy-hh-mm-ss/m-p/824202#M325462</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-07-19T17:21:25Z</dc:date>
    </item>
  </channel>
</rss>

