<?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: How to read csv file with space followed by quotation mark and line break in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710332#M218642</link>
    <description>&lt;P&gt;If you have no other tools for examining text files the SAS data step will work just fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'myfile.csv' ;
   input;
   list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really want to see what the end of line character is and if there are any in the middle of lines then you can read the file a fixed length and the end of line characters are treated as part of the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'myfile.csv'  refcm=f lrecl=100 ;
   input;
   list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 09 Jan 2021 00:22:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-09T00:22:04Z</dc:date>
    <item>
      <title>How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710051#M218497</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data step as below to read a csv file, but the memo field for some records jump to the next row in the output dataset.&lt;/P&gt;&lt;P&gt;I open the csv file in notepad and see the memo field seems to have double space before the quotation mark (not sure if that is the reason). See below data.&lt;/P&gt;&lt;P&gt;I also tried&amp;nbsp;&lt;SPAN&gt;TERMSTR=CRLF or&amp;nbsp;&lt;/SPAN&gt;TERMSTR=LF but I am still seeing the memo filed jumps to the next row.&lt;/P&gt;&lt;P&gt;Given there is not an option to fix the data quality from the upstream, is there a way to resolve this in the data step?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johnson and Johnson,REF35847,Monthly,159,"Sandigo, Luke [INVENTORY MANAGER]","Meet - Standard - Year1/Quarter1 - 35153194 stock 301463&lt;BR /&gt;INV#12011088&amp;nbsp; ",5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data inventory;
infile "/warehouse/users/Jack/inventory/inventory_20201130.csv" dlm= ',' missover DSD lrecl=32767 firstobs=2 ;
  input
    CompanyName      : $300.      
    Ref_ID                    : $50.
    Freq                        : $10.
    Value                       : 4.
    Salesperson            : $100.
    Memo                       :$200.
    ID                            :3.
;
run;&lt;/CODE&gt;&lt;/PRE&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>Thu, 07 Jan 2021 21:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710051#M218497</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-07T21:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710065#M218504</link>
      <description>&lt;P&gt;Try removing the missover option.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710065#M218504</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-07T22:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710068#M218506</link>
      <description>&lt;P&gt;Thanks for offering your suggestion. Without the missover, the memo value stays in the same row but part of the value moves to the next column (ID), and ID moves to the next row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect fixing the data quality from upstream might be the only way.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710068#M218506</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-07T22:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710073#M218511</link>
      <description>&lt;P&gt;Fixing the issue upstream would be the ideal solution. But if that can't be done, try posting a few lines from the csv file here, so that we can give it a better try.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2021 22:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710073#M218511</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-07T22:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710093#M218519</link>
      <description>&lt;P&gt;Thanks PG.&amp;nbsp;I realized there is embedded CRLF in the text after&amp;nbsp;stock 301463, so&amp;nbsp;INV#12011088 moves to the next row when SAS reads the data. I don't know if that is something fixable in SAS code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 00:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710093#M218519</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-08T00:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710095#M218520</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; might be able to help here...&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 00:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710095#M218520</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-08T00:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710109#M218530</link>
      <description>&lt;P&gt;Search for the other 25 gazillion times this question has been asked on the forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.google.com/search?q=%40sas.com+embedded+line+breaks+in+CSV+file" target="_blank"&gt;https://www.google.com/search?q=%40sas.com+embedded+line+breaks+in+CSV+file&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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>Fri, 08 Jan 2021 04:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710109#M218530</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T04:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710312#M218631</link>
      <description>&lt;P&gt;Thanks Tom. I saw those posts prior to asking my question on the forum. Later I found out my issue is not due to double quotation mark, extra space or line break, etc.&lt;/P&gt;&lt;P&gt;Embedded CRLF is found in the middle of the value for one filed (from the csv file I have), after reading it from SAS, it seems the embedded CRLF breaks the value into two separate parts - 1st part stays in the same row, remaining columns become missing, then 2nd part of the value jumps to next row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We couldn't resolve this issue in the SAS code and had to explore alternative solution.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 21:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710312#M218631</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-08T21:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710326#M218636</link>
      <description>&lt;P&gt;The linked post is a solution to handling embedded end of line characters in delimited files. As long as the fields that contain the extra end of line characters are enclosed in double quotes it should work to transform the file into a file that SAS can read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the best solution is to fix the problem at the source and generate delimited files that do not contain end of line characters anywhere other than at the end of the lines.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 23:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710326#M218636</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T23:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710330#M218640</link>
      <description>The end of life character is invisible in the csv file. I looked at the specific row of data in unix and found the CRLF in the middle of the record.</description>
      <pubDate>Sat, 09 Jan 2021 00:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710330#M218640</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-09T00:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710332#M218642</link>
      <description>&lt;P&gt;If you have no other tools for examining text files the SAS data step will work just fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'myfile.csv' ;
   input;
   list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really want to see what the end of line character is and if there are any in the middle of lines then you can read the file a fixed length and the end of line characters are treated as part of the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   infile 'myfile.csv'  refcm=f lrecl=100 ;
   input;
   list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Jan 2021 00:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710332#M218642</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-09T00:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710334#M218644</link>
      <description>I got your point. I though about using fixed length and treat the special/invisible character as part of the data, but I can’t be exactly sure how many invisible characters are there and where are they. I have around 100k obs and 125 variable.&lt;BR /&gt;The csv file is an output file/downstream from another upstream process. I suspect upstream data provider copied and pasted some texts from the website that carries CRLF.</description>
      <pubDate>Sat, 09 Jan 2021 00:34:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710334#M218644</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-09T00:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710338#M218646</link>
      <description>&lt;P&gt;No.&amp;nbsp; Use the fixed length just to LOOK at the file so you can figure out what garbage you have and how you can read it.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2021 01:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710338#M218646</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-09T01:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710573#M218760</link>
      <description>&lt;P&gt;The "&lt;SPAN&gt;garbage" is invisible neither in csv nor sas dataset. I tried the fix length&amp;nbsp;approach but it did not do anything in this situation. The "garbage" is only visible when we use unix command to read the file in putty. Again, I think the subject of this question is confusing because later I found out my issue is not due to space, quotation mark or line break etc. Thanks again for all your advice.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 15:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710573#M218760</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2021-01-11T15:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to read csv file with space followed by quotation mark and line break</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710597#M218773</link>
      <description>&lt;P&gt;To see how you can use the LIST statement to look at what is in your text file run this example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
data _null_;
  file csv ;
  put '1,2,3,"first part'
    / 'second part",5'
    / '6,7,8,"ok",10'
  ;
run;

data _null_;
  infile csv;
  input;
  list;
run;

data _null_;
  infile csv recfm=f lrecl=20 ;
  input;
  list;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first reading will show that the file has three "lines", none of which contain any characters that LIST considers as non-printing.&lt;/P&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+--
1         1,2,3,"first part 17
2         second part",5 14
3         6,7,8,"ok",10 13
NOTE: 3 records were read from the infile CSV.
      The minimum record length was 13.
      The maximum record length was 17.
&lt;/PRE&gt;
&lt;P&gt;The second reading will show you where the CR ('0D'x) and LF ('0A'x) appear in the file.&amp;nbsp; So you can see that there are CRLF pairs in the middle of the first string between FIRST PART and SECOND PART. And also that the file is using CRLF pairs at the end of the lines.&lt;/P&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+--

1   CHAR  1,2,3,"first part..s
    ZONE  32323226677727677007
    NUMR  1C2C3C26923400124DA3

2   CHAR  econd part",5..6,7,8
    ZONE  66666276772230032323
    NUMR  53FE4001242C5DA6C7C8

3   CHAR  ,"ok",10.. 10
    ZONE  2266223300
    NUMR  C2FB2C10DA
NOTE: 3 records were read from the infile CSV.
&lt;/PRE&gt;
&lt;P&gt;Other common non-printing characters are TAB '09'x FORM FEED '0C'x non-breaking space 'A0'x.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 16:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-csv-file-with-space-followed-by-quotation-mark-and/m-p/710597#M218773</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-11T16:08:40Z</dc:date>
    </item>
  </channel>
</rss>

