<?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: datalines anydtdtm40. cannot read datetimes with spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846731#M334717</link>
    <description>&lt;P&gt;If there is only a single space you could also just add the &amp;amp; modifier to the INPUT statement for that variable.&lt;/P&gt;
&lt;P&gt;That says that it requires two delimiters to indicate the end of a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are reading a single value from the line you could just use formatted input instead of LIST MODE input.&amp;nbsp; That will read the number of characters specified by the informat, whether or not there are any delimiter characters there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datalines_input ;
  input @1 dt1 &amp;amp; :anydtdtm. 
        @1 dt2 anydtdtm40.
  ;
  format dt1 dt2 datetime19.;
datalines ;
2022-05-07 02:10:00
2022-05-07:02:10:00
01JAN12 14:30:08
01JAN12:14:30:08
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs                    dt1                    dt2

 1      07MAY2022:02:10:00     07MAY2022:02:10:00
 2      07MAY2022:02:10:00     07MAY2022:02:10:00
 3      01JAN2012:14:30:08     01JAN2012:14:30:08
 4      01JAN2012:14:30:08     01JAN2012:14:30:08
&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Nov 2022 04:07:26 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-29T04:07:26Z</dc:date>
    <item>
      <title>datalines anydtdtm40. cannot read datetimes with spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846716#M334704</link>
      <description>&lt;P&gt;I'm thoroughly confused about the following behavior in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a csv file import with a datetime variable. It is imported the way I expect using anydtdtm40. I was tracking down a bug and tried to create a datalines statement to replicate part of my dataset but the anydtdtm40. does not seem to be able to read in the "time" portion of datetime values that contain a space (which is how it is written in the CVS file). I cannot determine if I'm doing something wrong in my datalines statement, or if this is an expected behavior. If it is an expected behavior, is there a workaround?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was reading up on the function of anydtdtm here:&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p1hsn1ji141r4zn0z3xm2dthop6a.htm" target="_blank" rel="noopener"&gt;https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p1hsn1ji141r4zn0z3xm2dthop6a.htm&lt;/A&gt;&amp;nbsp;which made it seem that a datetime value with a space should be okay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CVS File Import:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data cvs_file ;&lt;BR /&gt;%let _EFIERR_ = 0; /* set the ERROR detection macro variable */&lt;BR /&gt;infile "&amp;amp;dir.have.csv" delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;&lt;BR /&gt;informat datetimestuff anydtdtm40. ;&lt;BR /&gt;format datetimestuff datetime. ;&lt;BR /&gt;input&lt;BR /&gt;datetimestuff&lt;BR /&gt;;&lt;BR /&gt;if _ERROR_ then call symputx('_EFIERR_',1) ; /* set ERROR detection macro variable */&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CVS File Import Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;datetimestuff &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;07MAY22:02:10:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;07MAY22:02:10:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN12:14:30:08&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN12:14:30:08&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Datalines Statment (written the same way as in the CVS file):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data datalines_input ;&lt;BR /&gt;attrib datetimestuff informat=ANYDTDTM40. format=datetime. ;&lt;BR /&gt;input datetimestuff ;&lt;BR /&gt;datalines;&lt;BR /&gt;2022-05-07 02:10:00&lt;BR /&gt;2022-05-07:02:10:00&lt;BR /&gt;01JAN12 14:30:08&lt;BR /&gt;01JAN12:14:30:08&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Datalines Statement Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;datetimestuff &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;07MAY22:00:00:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;07MAY22:02:10:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN12:00:00:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN12:14:30:08&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Software&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;SAS 9.4 TS Level 1M7&lt;/LI&gt;&lt;LI&gt;X64_10PRO platform&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Operating System Information&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Windows Version 1.0.17763&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 29 Nov 2022 00:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846716#M334704</guid>
      <dc:creator>htalbott</dc:creator>
      <dc:date>2022-11-29T00:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: datalines anydtdtm40. cannot read datetimes with spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846730#M334716</link>
      <description>&lt;P&gt;Walked away and then proceeded to figure out how to make this work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data datalines_input ;
	infile datalines delimiter=',' ; 
	attrib datetimestuff informat=ANYDTDTM40. format=datetime. ;
	input datetimestuff ;
    datalines ;
2022-05-07 02:10:00
2022-05-07:02:10:00
01JAN12 14:30:08
01JAN12:14:30:08
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added this statement " infile datalines delimiter=',' ; "&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 03:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846730#M334716</guid>
      <dc:creator>htalbott</dc:creator>
      <dc:date>2022-11-29T03:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: datalines anydtdtm40. cannot read datetimes with spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846731#M334717</link>
      <description>&lt;P&gt;If there is only a single space you could also just add the &amp;amp; modifier to the INPUT statement for that variable.&lt;/P&gt;
&lt;P&gt;That says that it requires two delimiters to indicate the end of a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are reading a single value from the line you could just use formatted input instead of LIST MODE input.&amp;nbsp; That will read the number of characters specified by the informat, whether or not there are any delimiter characters there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datalines_input ;
  input @1 dt1 &amp;amp; :anydtdtm. 
        @1 dt2 anydtdtm40.
  ;
  format dt1 dt2 datetime19.;
datalines ;
2022-05-07 02:10:00
2022-05-07:02:10:00
01JAN12 14:30:08
01JAN12:14:30:08
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs                    dt1                    dt2

 1      07MAY2022:02:10:00     07MAY2022:02:10:00
 2      07MAY2022:02:10:00     07MAY2022:02:10:00
 3      01JAN2012:14:30:08     01JAN2012:14:30:08
 4      01JAN2012:14:30:08     01JAN2012:14:30:08
&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2022 04:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846731#M334717</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-29T04:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: datalines anydtdtm40. cannot read datetimes with spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846905#M334810</link>
      <description>Thanks Tom for the additional ways to make this work!</description>
      <pubDate>Tue, 29 Nov 2022 20:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datalines-anydtdtm40-cannot-read-datetimes-with-spaces/m-p/846905#M334810</guid>
      <dc:creator>htalbott</dc:creator>
      <dc:date>2022-11-29T20:04:49Z</dc:date>
    </item>
  </channel>
</rss>

