<?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: Error importing csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635488#M188694</link>
    <description>&lt;P&gt;Shame SAS &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Enhancements-to-INFILE-FILE-to-handle-delimited-file-variations/idi-p/435977" target="_self"&gt;decided&lt;/A&gt; not to address the issue.&lt;/P&gt;</description>
    <pubDate>Sun, 29 Mar 2020 02:50:55 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-03-29T02:50:55Z</dc:date>
    <item>
      <title>Error importing csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635460#M188676</link>
      <description>&lt;P&gt;I am trying to import a large CSV file into SAS. I tried to use both&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile = "rawdata.csv" dbms = csv out = mydata replace; getnames = yes;  run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
	infile "rawdata.csv" delimiter = ',' dsd missover lrecl = 32767 firstobs = 2;&amp;nbsp;...;&amp;nbsp;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;These two commands appear to generate the same dataset. However, only the second command leads to error messages in log. The messages are as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xyxu_0-1585351569950.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37487i554E9157AADB224A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xyxu_0-1585351569950.png" alt="xyxu_0-1585351569950.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To investigate the issue, I open the raw file in MS Access and go to row 2322547. The issue seems to be that a character variable has weird values:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xyxu_1-1585352133241.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37488iC6E9F55FFA705BC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xyxu_1-1585352133241.png" alt="xyxu_1-1585352133241.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And in the imported dataset, this value becomes&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xyxu_2-1585352174614.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37489i23EB6CBE15846F37/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xyxu_2-1585352174614.png" alt="xyxu_2-1585352174614.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried to use&amp;nbsp;encoding='utf-8' but it does not help. How can I correctly import this dataset?&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;s&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 23:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635460#M188676</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2020-03-27T23:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635466#M188678</link>
      <description>&lt;P&gt;Most likely you have poorly formed file. Perhaps it has some embedded line breaks in the middle of one the fields? This can cause the INPUT statement, either the one generated by PROC IMPORT or the one you wrote for your own data step, to get out of alignment with the values on the lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is your problem it is a common problem and has been answered on this forum many times.&amp;nbsp; You might be able to read it if the line breaks in the fields just use single carriage return or single linefeed and the actual real end of line codes in the file use both a carriage return and a linefeed.&amp;nbsp; If not then you need to pre-process the file to fix the issue by removing the extra line breaks.&lt;BR /&gt;&lt;BR /&gt;PS Why did you paste photographs of text? You can just copy and paste the lines of text from the SAS log.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 01:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635466#M188678</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-28T01:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635467#M188679</link>
      <description>&lt;P&gt;Thank, Tom. I found that the issue is due to hidden linebreakers in the string.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 01:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635467#M188679</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2020-03-28T01:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error importing csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635488#M188694</link>
      <description>&lt;P&gt;Shame SAS &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Enhancements-to-INFILE-FILE-to-handle-delimited-file-variations/idi-p/435977" target="_self"&gt;decided&lt;/A&gt; not to address the issue.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 02:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-importing-csv-file/m-p/635488#M188694</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-29T02:50:55Z</dc:date>
    </item>
  </channel>
</rss>

