<?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: datetime dates converted to wrong date when Imported from csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636138#M188935</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Show us the REAL contents of the csv file.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Everything else is just a waste of time.&lt;/P&gt;</description>
    <pubDate>Tue, 31 Mar 2020 10:05:33 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-03-31T10:05:33Z</dc:date>
    <item>
      <title>datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635771#M188821</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When import csv file with date column like below, SAS data will have&amp;nbsp;a small percentage&amp;nbsp;of rows&amp;nbsp;showing incorrect date, some dates become future dated. i.e. date 2020-03-09&amp;nbsp; may be converted to 3rd September&amp;nbsp;instead of 09 March.&amp;nbsp; I had similar issue with reading CSV using date format ddmmyy10. of which now resolved by using format date9. instead of using ddmmyy10.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess the solution might be similar to using a different format other than&lt;/P&gt;
&lt;P&gt;anydtdtm40. or datetime. ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me out?&lt;/P&gt;
&lt;P&gt;it is frustrating when you spot&amp;nbsp;some of the dates&amp;nbsp;were incorrectly converted and you have no&amp;nbsp;idea how to make it right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date in CSV file:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 141px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37538i8BF64FC50A62252D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS data:&lt;/P&gt;
&lt;P&gt;Left with wrong dates, right column is the correct date it should be showing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture1.PNG" style="width: 217px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37539i7A7CE89EAEC4C1DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Capture1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 11:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635771#M188821</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-30T11:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635772#M188822</link>
      <description>&lt;P&gt;Show us the code you are using. Show us a portion of the exact data set and then show us the results of running the code. You did not show us the data from the csv file that relates to the output you show.&amp;nbsp;The data you showed does not match in any way the results you show.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 11:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635772#M188822</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-30T11:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635777#M188825</link>
      <description>&lt;P&gt;&lt;FONT size="6"&gt;&lt;STRONG&gt;DO NOT POST DATA AS PICTURES!!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Copy/paste text data into a window opened with &amp;lt;/&amp;gt;, so we can readily use it.&lt;/P&gt;
&lt;P&gt;Post your code in a similar way, you can also use the next button (little running man) for this.&lt;/P&gt;
&lt;P&gt;Your timestamps can be easily read using the e8601dt informat:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input dt e8601dt19.;
format dt datetime19.;
datalines;
2020-02-21 00:00:00
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 11:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635777#M188825</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-30T11:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635789#M188828</link>
      <description>&lt;P&gt;What do the lines in the CSV file look like? You posted a photograph of what looks like part of a spreadsheet. A CSV file is a TEXT file.&amp;nbsp; Just copy and paste the lines of text from the file. Do NOT open the CSV file with Excel or any other spreadsheet program, they will change the contents into a spreadsheet instead of showing you the actual text in the file.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 12:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/635789#M188828</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-30T12:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636118#M188921</link>
      <description>&lt;P&gt;Hi Thank you all for your suggestions. My apologies not making the issue easier for helpers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there are a couple of macros being used in the programme to transfer CSV file from PC to server.&lt;/P&gt;
&lt;P&gt;The datetime column in csv looks like this (note the difference in the formula field to the cell):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 207px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37599i47F36425B4011443/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are the codes used to get the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;FTP_SAS_PC&lt;/I&gt;&lt;/STRONG&gt;(test_date,Import);&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test_date;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;DTDATE9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=test &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;nodupkey&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;the test data will show some incorrect dates where the day &amp;amp; month being misplaced.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;after changed the format for the dates column in CSV from ddmmyyyy to mmddyyyy, the issue resolved using the same code above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;When I changed the format to &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 09:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636118#M188921</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T09:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636132#M188931</link>
      <description>&lt;P&gt;It does &lt;STRONG&gt;NOT(!!)&lt;/STRONG&gt; look like this AT ALL.&lt;/P&gt;
&lt;P&gt;You are opening the csv file with Excel, what you see on the screen is what Excel makes out of it, which is usually quite some distance away from what's actually in there. It is quite possible that Excel converted the dates wrongly when reading the csv.&lt;/P&gt;
&lt;P&gt;DO NOT(!!) post data as pictures, pictures are USELESS.&lt;/P&gt;
&lt;P&gt;Open the csv file with a text editor, and copy/paste the text into a window opened with &amp;lt;/&amp;gt;. THIS IS MANDATORY AND ABSOLUTELY &lt;STRONG&gt;REQUIRED&lt;/STRONG&gt; for us to give proper help.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 09:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636132#M188931</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-31T09:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636137#M188934</link>
      <description>&lt;P&gt;Hi, my dear helpers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This issue exist when import CSV from PC to server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had an earlier issue which is similar but exist when export data to CSV from sas server to PC.&amp;nbsp; It was resolved with the help from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;who suggested change dates format from ddmmyy to mmddyy&amp;nbsp;as that is what excel likes (I guess it is to do with default settings in excel). I don't have any export dates issue ever since I changed the date format from ddmmyy10. to date9. for all sas data sets to be exported.&amp;nbsp; This stopped excel to incorrectly switch numbers (under 13) between month and day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I finally managed a work around to ensure dates are correctly imported from CSV file from PC to server by change the format in CSV(in excel) to mmddyy format (customized format).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wondered if there is an option set the default dates format that will in line with default settings between excel/csv to SAS environment?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the macro there is nothing set the dates format, but the log shows the date format(datetime.) and informat(anydtdtm40.):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 625px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37602i1653232F4B78D3CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 10:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636137#M188934</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T10:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636138#M188935</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Show us the REAL contents of the csv file.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Everything else is just a waste of time.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 10:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636138#M188935</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-31T10:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636140#M188936</link>
      <description>03/17/2020 0:00&lt;BR /&gt;03/10/2020 0:00&lt;BR /&gt;03/11/2020 0:00&lt;BR /&gt;03/11/2020 0:00&lt;BR /&gt;03/16/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/15/2020 0:00&lt;BR /&gt;03/15/2020 0:00</description>
      <pubDate>Tue, 31 Mar 2020 10:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636140#M188936</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T10:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636143#M188939</link>
      <description />
      <pubDate>Tue, 31 Mar 2020 10:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636143#M188939</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T10:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636146#M188942</link>
      <description>&lt;P&gt;Use the proper informats, and everything will be fine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input datepart :mmddyy10. timepart time5.;
dt = dhms(datepart,0,0,timepart);
format
  datepart yymmddd10.
  timepart time8.
  dt datetime19.
;
datalines;
03/17/2020 0:00
03/10/2020 0:00
03/11/2020 0:00
03/11/2020 0:00
03/16/2020 0:00
03/14/2020 0:00
03/14/2020 0:00
03/14/2020 0:00
03/14/2020 0:00
03/14/2020 0:00
03/14/2020 0:00
03/14/2020 0:00
03/15/2020 0:00
03/15/2020 0:00
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Mar 2020 10:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636146#M188942</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-31T10:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636147#M188943</link>
      <description>put the story short:&lt;BR /&gt;&lt;BR /&gt;The dates will be correctly imported when csv with data formatted below (mm/dd/yyyy):&lt;BR /&gt;03/14/2020 0:00&lt;BR /&gt;03/15/2020 0:00&lt;BR /&gt;03/15/2020 0:00 &lt;BR /&gt;&lt;BR /&gt;Some dates will be wrong when import from CSV with below data (yyyy-mm-dd):&lt;BR /&gt;2020-03-17 00:00:00&lt;BR /&gt;2020-03-10 00:00:00&lt;BR /&gt;&lt;BR /&gt;or (dd/mm/yyyy):&lt;BR /&gt;14/03/2020 0:00&lt;BR /&gt;09/03/2020 0:00&lt;BR /&gt;10/03/2020 0:00</description>
      <pubDate>Tue, 31 Mar 2020 10:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636147#M188943</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T10:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636148#M188944</link>
      <description>&lt;P&gt;If you have mixed formats in the spreadsheets, you should correct that first. SAS expects a consistent format for a given column throughout all rows.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 10:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636148#M188944</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-31T10:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636160#M188953</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; Thank you very much for your great support. I am really appreciated your time and effort in helping people out :).&lt;BR /&gt;&lt;BR /&gt;the data itself is nice and clean. but it will be converted to wrong dates if it were not using the format starting with mm instead of dd. (error occurred when days number &amp;lt;=12) &lt;BR /&gt;So, it worked when I manually changed the format to mm/dd/yy in excel. This is not an ideal solution and needs extra step on a daily basis.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Mar 2020 10:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636160#M188953</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T10:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636164#M188955</link>
      <description>The problem is that I can not see anywhere in the code the format anydtdtm40. or datetime. being used (as highlighted in the screenshot from the log file for the macro). Therefore I have no control to use the correct informat or format to read the date data from the CSV   &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Anyway, it worked by manually change the CSV file (using format mm/dd/yy) before import the CSV to SAS.&lt;BR /&gt;Thanks for all the helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 31 Mar 2020 10:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636164#M188955</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-03-31T10:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636174#M188962</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293494"&gt;@Suzy_Cat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good that you could resolve the issue for now. Reading through this discussion the following just for the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Difference between .csv and .xlsx&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A .csv is a comma delimited text file. The .csv format is closely tied to MS Excel and you can easily open it using Excel - but: Excel will parse the .csv text file and convert the "raw" values to what Excel "thinks" they are. And it will represent these internal values using default Excel formats. So opening a .csv with Excel is anything but "What You See is What You Get".&lt;/P&gt;
&lt;P&gt;With SAS you read .csv without any Excel involvement. SAS will basically do what Excel does: Impute and convert the text in the .csv into SAS variables. That's why everybody is always asking to show data not how it looks in Excel but in a Text editor like Notepad (which doesn't change anything).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Reading a .csv into SAS&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can either use Proc Import - which like Excel will first parse the text data, make some assumptions and then read the data into a SAS table. The result is very often what you need - but as it's based on assumptions SAS makes it's not always what you need/expect.&lt;/P&gt;
&lt;P&gt;You can also use a SAS data step. There you have to code for everything but you also have full control and can get what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now in your case you're obviously using SAS macro %&lt;STRONG&gt;&lt;I&gt;FTP_SAS_PC&lt;/I&gt;&lt;/STRONG&gt;(test_date,Import); someone else wrote. It's this SAS macro which creates the code reading the .csv text file into SAS. The SAS log you've posted shows what code the SAS macro generates to read the text file - so it's not only transferring the .csv it's also reading the data into a SAS file.&lt;/P&gt;
&lt;P&gt;The relevant bit which caused you pain is here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 255px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37604iCCE615D00B9FD55D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;A SAS informat instructs SAS how to read a text string into a SAS variable. Here it instructs SAS how to read a text string representing a date into a SAS numerical variable representing a date (which is the count of days since 1/1/1960). The special thing about the anydtdtm. informat: It accepts different patterns of source strings representing a date (like: 01Mar2020 or 01/03/2020 or 03/01/2020). It just tries one pattern after the other until it can convert the string. The documentation &lt;A href="https://go.documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1hsn1ji141r4zn0z3xm2dthop6a.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt; shows you which text patterns the informat tries. The problem is: "Some people" make a mess and have the month before the day. This leads to a situation where a text pattern representing a date becomes ambiguous. So 01/03/2020 can be 01Mar2020 or 03Jan2012. Because informat anydtdtm. will just try until it can convert a source string to a SAS date, the sequence how it tries is relevant - like does it first try a pattern of mm/dd/yyyy or first dd/mm/yyyy. If your .csv comes from the US then you likely want the informat to try mm/dd/yyyy first; else it's likely first dd/mm/yyyy.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can instruct SAS which sequence to use by setting option DATESTYLE documented &lt;A href="https://go.documentation.sas.com/?docsetId=nlsref&amp;amp;docsetTarget=n0cmg3tjkn6zmbn1od6pna244zm7.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;. If your macro reads some date values wrongly into SAS then investigate what you've actually got in the .csv and then set the DATESTYLE option accordingly prior to calling macro %FTP_SAS_PC()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 21:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636174#M188962</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-04-01T21:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636483#M189101</link>
      <description>Hi Patrick,&lt;BR /&gt;&lt;BR /&gt;Your advice is very thorough and definitely addressed my concern. You have pointed me to the right direction. The detailed info for sure will help me to understand the deep root cause.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;It will take me a while to go through all the readings and I enjoy the learning curve on the right journey.&lt;BR /&gt;&lt;BR /&gt;I really appreciated your patience. I struggled to describe the issue and almost gave up, had thought I won't be able make it clearer for people to understand where I was stuck.&lt;BR /&gt;&lt;BR /&gt;Thank you sincerely. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Apr 2020 10:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636483#M189101</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-04-01T10:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: datetime dates converted to wrong date when Imported from csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636504#M189107</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;!  That worked like a charm.&lt;BR /&gt;I have tested and now have full control.  The data quality issue resolved perfectly.&lt;BR /&gt;&lt;BR /&gt;So just choose the right option relevant to date format in the CSV file &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;OPTIONS DATESTYLE= MDY | YMD | DMY | LOCALE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Apr 2020 11:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datetime-dates-converted-to-wrong-date-when-Imported-from-csv/m-p/636504#M189107</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-04-01T11:44:09Z</dc:date>
    </item>
  </channel>
</rss>

