<?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: Informat for dd/mm/yyyy hh:mm:ss in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489228#M127690</link>
    <description>&lt;P&gt;Please use the below code in your datastep for the date variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
INFILE '/home/test.csv' dsd;
 
 input datevar:ANYDTDTM.;
 
 format datevar DATETIME19.;
put datevar= DATETIME19.;
 
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Aug 2018 12:37:50 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2018-08-23T12:37:50Z</dc:date>
    <item>
      <title>Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489223#M127688</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently trying to import a CSV file&amp;nbsp;and keep getting the below Note;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966" face="courier new,courier"&gt;NOTE: Invalid data for STARTDATE in line 2 444-462.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;I know that this is being caused due to the data which is trying to be read in is &lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;22/07/2018 09:56:20 in the UK format of dd/mm/yyyy hh:mm:ss but I cannot seem to find the right informat to properly read the data.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;I have tried DATE, DATETIME, ANDTTME, even E8601DX&amp;nbsp;(all with a width of 16) but nothing seems to work.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT face="Arial"&gt;I am using a data step and defining lengths, formats, informats etc., and I am also using SAS EG 7.15 (7.100.5.5850) (64-bit) to access&amp;nbsp; a LINUX server running 9.4.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif"&gt;&lt;FONT face="Arial"&gt;Any help would be greatly appreciated.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 12:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489223#M127688</guid>
      <dc:creator>TW_</dc:creator>
      <dc:date>2018-08-23T12:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489228#M127690</link>
      <description>&lt;P&gt;Please use the below code in your datastep for the date variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
INFILE '/home/test.csv' dsd;
 
 input datevar:ANYDTDTM.;
 
 format datevar DATETIME19.;
put datevar= DATETIME19.;
 
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 12:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489228#M127690</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-23T12:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489236#M127694</link>
      <description>&lt;P&gt;Personally, I would prefer to force strict formats. I don't trust the guessing involved by using the ANYDTDTM informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input string $19.;
datetime_value = dhms(input(substr(string,1,10),ddmmyy10.),0,0,input(substr(string,12),time8.));
format datetime_value e8601dt19.;
cards;
22/07/2018 09:56:20
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 12:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489236#M127694</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-23T12:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489239#M127697</link>
      <description>&lt;P&gt;You can find the answer by yourself, In SAS EG use the Import Wizard (File&amp;gt;Import Data in SAS Eg) to read the data from CSV. Import wizard will anatomically identify the informat and formats in most of the cases.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will create the code and you can copy the code and make some changes as per your requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this scenario it gave me&amp;nbsp;&lt;STRONG&gt;ANYDTDTM19. &lt;/STRONG&gt;informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 12:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/489239#M127697</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-23T12:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/521896#M141635</link>
      <description>&lt;P&gt;I have to say this is the worst format to take for import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;ANYDTDTM19. &lt;/STRONG&gt;informat is choosing format for each single new line, and makes serious mistakes when month and day can be misunderstood. For example 12JUN2018 (12.06.2018) will by rule always misinterpreted as 06DEC2018.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is why it is very important to set &lt;SPAN style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;SPAN style="color: blue;"&gt;options&lt;/SPAN&gt; datestyle=dmy;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;to make it sure that day is read always first.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/521896#M141635</guid>
      <dc:creator>trt</dc:creator>
      <dc:date>2018-12-17T13:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/767756#M243442</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I tried to use this suggestion to read in data that came to me like this&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;6/28/2021 22:51&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/28/2021 23:41&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/29/2021 2:18&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/29/2021 5:35&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6/29/2021 2:13&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I modified the string to be 1,9 and the date to be mmddyy but no luck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 15:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/767756#M243442</guid>
      <dc:creator>mwstat</dc:creator>
      <dc:date>2021-09-14T15:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/767784#M243453</link>
      <description>&lt;P&gt;You need to adapt the statement to the variable length of the date, the MDY order, and the shorter time:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetime_value = dhms(input(scan(string,1),mmddyy10.),0,0,input(scan(string,2),time5.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 17:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/767784#M243453</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-14T17:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/790728#M253184</link>
      <description>&lt;P&gt;Thanks for the suggestions. I wanted to come back and say that I have also had success using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want1;&lt;BR /&gt;set attempt_nov;&lt;BR /&gt;time_created1= timepart(DTAttempt);&lt;BR /&gt;date_created1 = datepart(DTAttempt);&lt;BR /&gt;week1=week(date_created1);&lt;BR /&gt;format date_created1 mmddyy10. time_created1 time.;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 17:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/790728#M253184</guid>
      <dc:creator>mwstat</dc:creator>
      <dc:date>2022-01-18T17:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/790751#M253194</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/397964"&gt;@mwstat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the suggestions. I wanted to come back and say that I have also had success using&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want1;&lt;BR /&gt;set attempt_nov;&lt;BR /&gt;time_created1= timepart(DTAttempt);&lt;BR /&gt;date_created1 = datepart(DTAttempt);&lt;BR /&gt;week1=week(date_created1);&lt;BR /&gt;format date_created1 mmddyy10. time_created1 time.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That will only work if you already have a DATETIME variable, not the character string that the original question is asking about.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 19:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/790751#M253194</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-18T19:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/854786#M337838</link>
      <description>This answer is actually wrong because ANYHDTDTM will assume MM-DD-YYYY first over DD-MM-YYYY. If you give it 12-01-2023 it will read it as the 1st of December, but it should the 12th of January.</description>
      <pubDate>Fri, 20 Jan 2023 10:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/854786#M337838</guid>
      <dc:creator>SanderB</dc:creator>
      <dc:date>2023-01-20T10:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Informat for dd/mm/yyyy hh:mm:ss</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/854803#M337840</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420625"&gt;@SanderB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This answer is actually wrong because ANYHDTDTM will assume MM-DD-YYYY first over DD-MM-YYYY. If you give it 12-01-2023 it will read it as the 1st of December, but it should the 12th of January.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is not (entirely) correct. The ANY... informats will prefer DMY or MDY depending on the DATESTYLE system option (which has a default setting of LOCALE, which means the current locale setting also influences the date order).&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 11:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat-for-dd-mm-yyyy-hh-mm-ss/m-p/854803#M337840</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-20T11:13:37Z</dc:date>
    </item>
  </channel>
</rss>

