<?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 Using infile but all the dates are missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270014#M53573</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a csv file which is delimited by '|' and my dates are all in this format "2015-10-31 00:00".&lt;/P&gt;&lt;P&gt;Hence, I code using this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'File path' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat PostDate ANYDTDTM32. ;
informat OpenDate ANYDTDTM32. ;

format PostDate DATE9. ;
format OpenDate DATETIME16. ;

input
PostDate
OpenDate
;  
if _ERROR_ then call symput('_EFIERR_',1);  /* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All my other fields are importing correctly but only the dates are impacted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for the PostDate, I do not want the time, but for the OpenDate, I will want the time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have compared the number of variables but all tallied up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm really confused about this problem and there are no error messages in the Log to indicate what is the error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I'm using PROC IMPORT, it is fine. But there are empty date fields, which will make it Character instead of Numeric. Hence, I choose to use infile for importing the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate if anyone can help me!&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2016 10:24:38 GMT</pubDate>
    <dc:creator>LaiQ</dc:creator>
    <dc:date>2016-05-12T10:24:38Z</dc:date>
    <item>
      <title>Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270014#M53573</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a csv file which is delimited by '|' and my dates are all in this format "2015-10-31 00:00".&lt;/P&gt;&lt;P&gt;Hence, I code using this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'File path' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat PostDate ANYDTDTM32. ;
informat OpenDate ANYDTDTM32. ;

format PostDate DATE9. ;
format OpenDate DATETIME16. ;

input
PostDate
OpenDate
;  
if _ERROR_ then call symput('_EFIERR_',1);  /* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All my other fields are importing correctly but only the dates are impacted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for the PostDate, I do not want the time, but for the OpenDate, I will want the time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have compared the number of variables but all tallied up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm really confused about this problem and there are no error messages in the Log to indicate what is the error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I'm using PROC IMPORT, it is fine. But there are empty date fields, which will make it Character instead of Numeric. Hence, I choose to use infile for importing the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate if anyone can help me!&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 10:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270014#M53573</guid>
      <dc:creator>LaiQ</dc:creator>
      <dc:date>2016-05-12T10:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270016#M53575</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82677"&gt;@LaiQ﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To extract the date part of a datetime value by means of an informat, you should use the ANYDTDTE&lt;EM&gt;w&lt;/EM&gt;. informat:&lt;/P&gt;
&lt;PRE&gt;informat PostDate ANYDTDT&lt;STRONG&gt;E&lt;/STRONG&gt;. ;&lt;/PRE&gt;
&lt;P&gt;What is your problem with OpenDate, if any?&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 10:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270016#M53575</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-12T10:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270017#M53576</link>
      <description>Ooh, I have changed it. But all my dates are still missing... The OpenDate is the same format as my PostDate. So I don't think there should be any problem right?</description>
      <pubDate>Thu, 12 May 2016 10:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270017#M53576</guid>
      <dc:creator>LaiQ</dc:creator>
      <dc:date>2016-05-12T10:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270018#M53577</link>
      <description>&lt;P&gt;The below data step works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile cards dlm='|' missover dsd;
informat PostDate ANYDTDTE.
         OpenDate ANYDTDTM32. ;

format PostDate DATE9.
       OpenDate DATETIME16. ;

input PostDate OpenDate;
cards;
2015-10-31 00:00|2015-10-31 00:00
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Therefore, I suspect there is an issue with your data. Could you please post two or three lines of your file (with confidential information overtyped with 'xxxxx', if necessary)?&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 10:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270018#M53577</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-12T10:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270019#M53578</link>
      <description>&lt;P&gt;You wrote that "&lt;SPAN&gt;there are no error messages in the Log," but there could be &lt;EM&gt;notes&lt;/EM&gt;&amp;nbsp;indicating data issues. So, showing the relevant part of your log might help, too.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270019#M53578</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-12T11:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270020#M53579</link>
      <description>&lt;P&gt;Hmm, I tried using only 2 lines of the data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PostDate|CardID|CardType|OpenDate&lt;BR /&gt;2015-09-30 00:00|1311364|0|2015-01-04 00:00&lt;BR /&gt;2015-09-30 00:00|959623|0|2010-05-06 00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And using the codes:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'FILE PATH' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2 ;
informat PostDate ANYDTDTE. ;
informat CardID best32. ;
informat CardType best32. ;
informat OpenDate ANYDTDTM32. ;

format PostDate DATE9. ;
format CardID best12. ;
format CardType best12. ;
format OpenDate DATETIME16. ;

input
PostDate
CardID
CardType
OpenDate
;  
if _ERROR_ then call symput('_EFIERR_',1);  /* set ERROR detection macro variable */
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The message in the log:&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;3316:40&lt;BR /&gt;NOTE: The infile 'FILE PATH' is:&lt;BR /&gt;File Name=FILE PATH,&lt;BR /&gt;RECFM=V,LRECL=32767&lt;/P&gt;&lt;P&gt;NOTE: 2 records were read from the infile 'FILE PATH'.&lt;BR /&gt;The minimum record length was 42.&lt;BR /&gt;The maximum record length was 43.&lt;BR /&gt;NOTE: The data set WANT&amp;nbsp;has 2 observations and 4 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270020#M53579</guid>
      <dc:creator>LaiQ</dc:creator>
      <dc:date>2016-05-12T11:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270021#M53580</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;, I managed to get the output if I use:&lt;/P&gt;&lt;P&gt;informat PostDate YMDDTTM32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the format PostDate Date16. will not work. But I still managed to read the date in...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess perhaps the informat is wrong in the first place...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to waste your time!&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270021#M53580</guid>
      <dc:creator>LaiQ</dc:creator>
      <dc:date>2016-05-12T11:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270023#M53581</link>
      <description>&lt;P&gt;POSTDATE takes on datetime values, not date values. &amp;nbsp;Using a date format won't work. &amp;nbsp;If you want to convert POSTDATE to a date value, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;postdate = datepart(postdate);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can apply date formats to it.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270023#M53581</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-12T11:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270025#M53582</link>
      <description>&lt;P&gt;I've run your code (with the data you provided) successfully &lt;EM&gt;without&lt;/EM&gt; any change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that the YMDDTTM&lt;EM&gt;w.d&lt;/EM&gt; informat reads &lt;EM&gt;datetime&lt;/EM&gt; values. That is, you don't get SAS &lt;EM&gt;date&lt;/EM&gt; values (which is what you said you wanted), but SAS &lt;EM&gt;datetime&lt;/EM&gt; values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Format Date16. doesn't work, because the width w of the DATE&lt;EM&gt;w&lt;/EM&gt;. format is limited to the range 5 - 11.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if you read PostDate with YMDDTTM32., you cannot assign a date format to&amp;nbsp;variable PostDate, but you have to use a format that works for datetime values. Format DTDATE9., for example, displays the date part of a datetime value in the form &lt;EM&gt;ddmmmyyyy&lt;/EM&gt;. This could be suitable for your purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270025#M53582</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-12T11:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using infile but all the dates are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270077#M53607</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/82677"&gt;@LaiQ&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;, I managed to get the output if I use:&lt;/P&gt;
&lt;P&gt;informat PostDate YMDDTTM32.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the format PostDate Date16. will not work. But I still managed to read the date in...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess perhaps the informat is wrong in the first place...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry to waste your time!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could also try YYMMDD10. on reading which would likely just ignore the time portion.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 14:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-infile-but-all-the-dates-are-missing/m-p/270077#M53607</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-12T14:11:51Z</dc:date>
    </item>
  </channel>
</rss>

