<?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: Importing Pipe delimited file with Carriage Returns in String in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256938#M9555</link>
    <description>&lt;P&gt;This could give you a start . You need change the code according to your real data. Especiall which one is the start of a row .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile '/folders/myfolders/x.txt' dsd delimiter='|'  recfm=n ;
input (x) (: $40.) @@ ;
x1=scan(x,1,'0D0A'x);
x2=scan(x,2,'0D0A'x);
if notdigit(strip(x2))=0 and not missing(x2) then do;
 x=x1;output;
 group+1;x=x2;output;
end;
else output;
drop x1 x2;
run;

proc transpose data=have out=want(drop=_:);
by group;
var x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2016 01:32:44 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-03-16T01:32:44Z</dc:date>
    <item>
      <title>Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256874#M9547</link>
      <description>&lt;P&gt;I need to import a pipe delimited file in which the character columns are within quotes (" "). However some of these columns contain a Carriage Return (probably when enter pressed while filling in the data in same cell). Hence the data is looking something like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var1 | "Var2" | Var3&lt;/P&gt;&lt;P&gt;1 | "Hi. This contains a break&lt;/P&gt;&lt;P&gt;here" |&amp;nbsp;105&lt;/P&gt;&lt;P&gt;2 | "Another break&lt;/P&gt;&lt;P&gt;here and&lt;/P&gt;&lt;P&gt;here" | 109&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS 9.2. Can someone help me out in order to resolve the issue and import it into SAS as :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var1 | "Var2" | Var3&lt;/P&gt;&lt;P&gt;1 | "Hi. This contains a break&amp;nbsp;here" |&amp;nbsp;105&lt;/P&gt;&lt;P&gt;2 | "Another break&amp;nbsp;here and&amp;nbsp;here" | 109&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Gaurav&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 18:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256874#M9547</guid>
      <dc:creator>gaurav_248</dc:creator>
      <dc:date>2016-03-15T18:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256875#M9548</link>
      <description>&lt;P&gt;It is probably linefeed 0Ax. &amp;nbsp;Try using INFILE statement option TERMSTR=CRLF. &amp;nbsp; Assuming your records are DOS based. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 19:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256875#M9548</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-03-15T19:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256876#M9549</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying. I already tried the option but it didn't work out.&lt;/P&gt;&lt;P&gt;Is there any other alternative available?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 19:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256876#M9549</guid>
      <dc:creator>gaurav_248</dc:creator>
      <dc:date>2016-03-15T19:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256880#M9550</link>
      <description>&lt;P&gt;Please post a sample of your file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 19:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256880#M9550</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-15T19:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256886#M9552</link>
      <description>I have edited the text of the data in order to remove confidential information. But the structure is the same.&lt;BR /&gt;____________________________________________________________&lt;BR /&gt;ID_IYXZ|ID_LMNO|TX_ABCD|&lt;BR /&gt;1|343|"O QUE YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYL?"|&lt;BR /&gt;1|345|"O ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ?"|&lt;BR /&gt;1|347|"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP?"|&lt;BR /&gt;1|344|"SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS?&lt;BR /&gt;&lt;BR /&gt;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ."|&lt;BR /&gt;___________________________________________________________________________</description>
      <pubDate>Tue, 15 Mar 2016 19:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256886#M9552</guid>
      <dc:creator>gaurav_248</dc:creator>
      <dc:date>2016-03-15T19:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256918#M9553</link>
      <description>&lt;P&gt;I found this as a working solution.&lt;/P&gt;&lt;P&gt;Working on the raw csv in binary format and removing special characters, then simply proc import the new csv.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;infile cdata lrecl=1 recfm=n end=eof;&lt;BR /&gt;file outdata lrecl=1000000;&lt;BR /&gt;nq=0;&lt;BR /&gt;do until (eof or (char='0A'X and mod(nq,2)=0));&lt;BR /&gt;input char $char1.;&lt;BR /&gt;nq=nq+(char='"') ;&lt;BR /&gt;if char not in ('0D'x,'0A'x) then do;&lt;BR /&gt;char1 = prxchange('s/[^\x20-\x7E\x0A\x0D]//', -1, char);&lt;BR /&gt;if missing(char)=1 or missing(char1)=0 then put char1 $char1. @ ;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;put ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone confirm this and please explain any drawbacks/problems this might cause?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 21:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256918#M9553</guid>
      <dc:creator>gaurav_248</dc:creator>
      <dc:date>2016-03-15T21:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256929#M9554</link>
      <description>&lt;P&gt;Thanks for suggesting your own solution. I see two possibly minor drawbacks:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;According to your first&amp;nbsp;post you wanted to replace line breaks with single blanks. With the suggested&amp;nbsp;approach, however, the lines (within a quoted string) would be concatenated without inserting blanks.&lt;/LI&gt;
&lt;LI&gt;Special characters from the range '80'x - 'FF'x (e.g. "µ") would be removed.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you&amp;nbsp;could first find out&amp;nbsp;&lt;SPAN&gt;what type of line break really occurs within the&amp;nbsp;quoted strings.&amp;nbsp;Just open the text file&lt;/SPAN&gt;&amp;nbsp;with a hex editor or read (relevant parts of) it with SAS using INFILE with RECFM=F and display the contents in $HEX&lt;EM&gt;w&lt;/EM&gt;. format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length string $32;
infile cdata recfm=f lrecl=32 truncover obs=10;
input string $char32.;
put string $hex64.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You wrote that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__﻿&lt;/a&gt;'s promising&amp;nbsp;suggestion "didn't work out." This would be the case if the line breaks in your quoted strings were CRLF ('0D0A'x) characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case you could use the little program from&amp;nbsp;&lt;A href="http://support.sas.com/techsup/technote/ts673.pdf" target="_blank"&gt;http://support.sas.com/techsup/technote/ts673.pdf&lt;/A&gt;, p. 6 (which is similar to yours, but targeted at&amp;nbsp;LF characters) to overwrite&amp;nbsp;the LFs ('0A'x) within quoted strings with blanks. (To avoid overwriting the original text file, you could, of course, use &lt;FONT face="courier new,courier"&gt;file outdata ...&lt;/FONT&gt;&amp;nbsp;as in your approach.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could then read the modified file as usual, remove the remaining CR ('0D'x) characters and compress multiple blanks (from multiple line breaks as in your sample data) to single blanks (unless there are other multiple blanks which are worth preserving):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length ID_IYXZ ID_LMNO 8 TX_ABCD $256; /* please adapt length as appropriate */
infile outdata dlm='|' dsd firstobs=2;
input ID_IYXZ ID_LMNO TX_ABCD :$quote.;
TX_ABCD=compbl(compress(TX_ABCD, '0D'x));
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>Tue, 15 Mar 2016 23:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256929#M9554</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-15T23:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256938#M9555</link>
      <description>&lt;P&gt;This could give you a start . You need change the code according to your real data. Especiall which one is the start of a row .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile '/folders/myfolders/x.txt' dsd delimiter='|'  recfm=n ;
input (x) (: $40.) @@ ;
x1=scan(x,1,'0D0A'x);
x2=scan(x,2,'0D0A'x);
if notdigit(strip(x2))=0 and not missing(x2) then do;
 x=x1;output;
 group+1;x=x2;output;
end;
else output;
drop x1 x2;
run;

proc transpose data=have out=want(drop=_:);
by group;
var x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 01:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/256938#M9555</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-16T01:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Pipe delimited file with Carriage Returns in String</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/257004#M9556</link>
      <description>Thank you so much. You were right about the drawbacks.&lt;BR /&gt;We are working with Portuguese text and some characters with accents were getting removed. But a small tweak in the characters we need removed solved that issue.&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Mar 2016 12:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Importing-Pipe-delimited-file-with-Carriage-Returns-in-String/m-p/257004#M9556</guid>
      <dc:creator>gaurav_248</dc:creator>
      <dc:date>2016-03-16T12:54:40Z</dc:date>
    </item>
  </channel>
</rss>

