<?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: Csv file import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740286#M231214</link>
    <description>&lt;P&gt;Details matter.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the values with the inserted end-of-line characters are quoted then it is easy to fix.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Reading-CSV-file-with-double-quotes-line-breaks-and-spaces/td-p/505738" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Reading-CSV-file-with-double-quotes-line-breaks-and-spaces/td-p/505738&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 May 2021 20:56:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-10T20:56:55Z</dc:date>
    <item>
      <title>Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740260#M231195</link>
      <description>I have a Csv file (number of rows and columns can change)—text data can contain Latin character, open quote, delimiter (,), and line spaced.&lt;BR /&gt;Is there a way to read without informat/format and reading all variables by names?&lt;BR /&gt;When I used proc import with encoding=‘Any’ the variables were shifted (Some values from some columns headings were shifted to different columns). Thank you.</description>
      <pubDate>Mon, 10 May 2021 19:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740260#M231195</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-05-10T19:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740264#M231198</link>
      <description>&lt;P&gt;Show an example of a line where the values "shift".&lt;/P&gt;
&lt;P&gt;If you data has the delimiter character in it (which is normally a comma for a Comma Separated Values file) then those values need to be enclosed in quotes.&amp;nbsp; Otherwise there is no way to parse the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider the case of a field with variable A,B and C.&amp;nbsp; A=1, B='2,3,4' and C=5 and you generate a comma delimited files without quoting the value of B you get a line like:&lt;/P&gt;
&lt;PRE&gt;1,2,3,4,5&lt;/PRE&gt;
&lt;P&gt;Which has 5 values, not 3 values.&lt;/P&gt;
&lt;P&gt;Once you add the quotes then it has three values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1,"2,3,4",5&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have a file that was generated improperly you MIGHT be able to interpret it, but only if the delimiters can only appear in one of the fields.&amp;nbsp; So in the example you can take A from the left and C from the right and whatever is left over is the value of B.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 20:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740264#M231198</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-10T20:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740266#M231199</link>
      <description>I deprecated by |, but still could not import properly. I think it is because there are random line spaces. How can I remove/fix those in Sas? Thank you.</description>
      <pubDate>Mon, 10 May 2021 20:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740266#M231199</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-05-10T20:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740271#M231203</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381519"&gt;@Emma2021&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I deprecated by |, but still could not import properly. I think it is because there are random line spaces. How can I remove/fix those in Sas? Thank you.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Post example data of what you mean by "random line spaces".&lt;/P&gt;
&lt;P&gt;Open a text box on the forum with the &amp;lt;/&amp;gt; icon, copy a few lines that show the behavior from your file opened in a text editor like Notepad or similar, and paste into the window opened on the forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you mean that different lines have different order of variables, or different variables, is there a pattern to tell which are which?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have written code to read as many as 25 different file "layouts" inside a single file but details matter in such things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any documentation from the source about the file structure, Variable types or lengths, date value appearance?&lt;/P&gt;
&lt;P&gt;If you don't have any of this you add a lot of headaches to "guess until it doesn't fail" type coding.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 20:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740271#M231203</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-10T20:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740276#M231207</link>
      <description>I do not want to open each csv file and fix the line (inserted a new line within one text variable)—since there are many csv files. Is there a way to fix those random new lines were inserted within one text variable?</description>
      <pubDate>Mon, 10 May 2021 20:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740276#M231207</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-05-10T20:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740279#M231209</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381519"&gt;@Emma2021&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I do not want to open each csv file and fix the line (inserted a new line within one text variable)—since there are many csv files. Is there a way to fix those random new lines were inserted within one text variable?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Exactly.&amp;nbsp; That is why we asked you to open one of the files with issues and copy and paste a few of the lines where the issue appears and paste it into the Insert Code box that pops up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once we can see examples of the issue we can give you advice on whether or not a programmatic solution to clean up the files is possible.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 20:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740279#M231209</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-10T20:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740281#M231211</link>
      <description>&lt;P&gt;I assume you meant delimited.&lt;/P&gt;
&lt;P&gt;Changing the delimiter to one that is less common reduces the chances of files that cannot be parsed, but does not eliminate the issue.&amp;nbsp; Unless the process of creating the files makes sure to remove any delimiters that appear in the data before generating the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the source of these files?&amp;nbsp; Are you making them yourself?&amp;nbsp; Are they all historical? Or do you plan to get more in the future?&lt;/P&gt;
&lt;P&gt;If you are making them yourself then how are you making them?&amp;nbsp; Are you generating them from some database system? What system? What command are you using?&lt;/P&gt;
&lt;P&gt;If you are getting them from someone else what agreements did you put in place in advance to make sure they delivered files that can be read?&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 20:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740281#M231211</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-10T20:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740285#M231213</link>
      <description>Sorry, I don’t have my pc now.&lt;BR /&gt;A new line means as below:&lt;BR /&gt;After&lt;BR /&gt;the&lt;BR /&gt;dinner, all @&lt;BR /&gt;Etc. I made up an pseudo data. Thank you</description>
      <pubDate>Mon, 10 May 2021 20:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740285#M231213</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-05-10T20:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740286#M231214</link>
      <description>&lt;P&gt;Details matter.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the values with the inserted end-of-line characters are quoted then it is easy to fix.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Reading-CSV-file-with-double-quotes-line-breaks-and-spaces/td-p/505738" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Reading-CSV-file-with-double-quotes-line-breaks-and-spaces/td-p/505738&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 20:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740286#M231214</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-10T20:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740291#M231217</link>
      <description>Not always the end of variable has a new line space. Sometimes in the middle of variables have random new line spaces (I think even within 252 character length).</description>
      <pubDate>Mon, 10 May 2021 21:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740291#M231217</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-05-10T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Csv file import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740297#M231220</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381519"&gt;@Emma2021&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I do not want to open each csv file and fix the line (inserted a new line within one text variable)—since there are many csv files. Is there a way to fix those random new lines were inserted within one text variable?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is actually random, then almost certainly there is no "good" programming method to fix it? But are you sure they are actually "random" or based on content.&amp;nbsp; What is the response to the question about file layout documentation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And did you open any of these in a spreadsheet program and then save it?&amp;nbsp; That can change the actual content.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 21:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Csv-file-import/m-p/740297#M231220</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-10T21:05:19Z</dc:date>
    </item>
  </channel>
</rss>

