<?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: count specific char in line and put linefeed at specific cnt in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611802#M178405</link>
    <description>&lt;P&gt;The right solution depends on how the file is formatted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the values with embedded CR and/or LF characters enclosed in quotes?&amp;nbsp; If they are then the solution posted by SAS that counts quotes will work.&amp;nbsp;&amp;nbsp;&lt;A href="http://support.sas.com/kb/26/065.html" target="_blank"&gt;http://support.sas.com/kb/26/065.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Do the values ever contain actual British pound symbols?&amp;nbsp; If not then just counting the number of pound symbols might work.&amp;nbsp; But it will get tricky if the embedded line breaks appear in the last value on the line.&lt;/P&gt;
&lt;P&gt;If yes then how have the protected those symbols so that you can tell which are delimiters and which are data?&amp;nbsp; There are two normally used styles.&amp;nbsp; One is to enclose the value in quotes (that is what SAS does and the DSD infile option supports). The other is the "escape" the character by preceding it with a special character, normally the backslash, \ , character.&lt;/P&gt;</description>
    <pubDate>Sat, 14 Dec 2019 17:25:48 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-12-14T17:25:48Z</dc:date>
    <item>
      <title>count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611792#M178398</link>
      <description>&lt;P&gt;Hi Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to prepare a file with a speciel format&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it is a csv format but with a pund sign(£) as delimiter and a lot if linefeeds/carriage returns in some of the&amp;nbsp; text columns.&lt;/P&gt;&lt;P&gt;a line in my file with look like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;col1£col2£col3£col4£col5$&lt;BR /&gt;myname£myaftername£myaddress£this is a text column&lt;BR /&gt;wtih crlf all over&lt;BR /&gt;the place £col5_account&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now i am trying to remove those crtl by count the oocourence if £ and remove them until the end of line, but a am still a newbie in SAS programming so i hoped for some kind advice in this forum.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My approach until now has been this peace of code, it is based on an example from SAS removing crtl inside quoted text columns&lt;/P&gt;&lt;P&gt;but i cant get my count to work properly and uit just writes \n all over right now.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let repA='@';                    /* replacement character LF */
%let repD='$';                    /* replacement character CR */

                             
%let dsnnme="/folders/myfolders/testdata.txt";

      /* use full path of CSV file */

data test;
  infile &amp;amp;dsnnme recfm=n sharebuffers;
  file &amp;amp;dsnnme recfm=n;

  retain open 0;
   length cnt 8.;
   retain cnt 0;
  input a $char1.;
  /* If the character is a £ i increment the cnt variable by 1 */
  if a = 'A3'x then&lt;BR /&gt;     cnt = cnt + 1;
   
  /* if cnt is not end of line remove any crtl */
                             */
  
  if cnt &amp;lt; 5 then do;
    if a = '0D'x then put &amp;amp;repD;
    else if a = '0A'x then put &amp;amp;repA;
  end;
  if cnt = 5 then do;
  /* this should capture the end of line */
  cnt = 0;
 end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2019 12:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611792#M178398</guid>
      <dc:creator>havmaage</dc:creator>
      <dc:date>2019-12-14T12:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611799#M178403</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/257901"&gt;@havmaage&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show the output you require?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 15:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611799#M178403</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-12-14T15:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611802#M178405</link>
      <description>&lt;P&gt;The right solution depends on how the file is formatted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the values with embedded CR and/or LF characters enclosed in quotes?&amp;nbsp; If they are then the solution posted by SAS that counts quotes will work.&amp;nbsp;&amp;nbsp;&lt;A href="http://support.sas.com/kb/26/065.html" target="_blank"&gt;http://support.sas.com/kb/26/065.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Do the values ever contain actual British pound symbols?&amp;nbsp; If not then just counting the number of pound symbols might work.&amp;nbsp; But it will get tricky if the embedded line breaks appear in the last value on the line.&lt;/P&gt;
&lt;P&gt;If yes then how have the protected those symbols so that you can tell which are delimiters and which are data?&amp;nbsp; There are two normally used styles.&amp;nbsp; One is to enclose the value in quotes (that is what SAS does and the DSD infile option supports). The other is the "escape" the character by preceding it with a special character, normally the backslash, \ , character.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 17:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611802#M178405</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-14T17:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611804#M178407</link>
      <description>&lt;P&gt;First thing is to not overwrite your original file. Make a new file with the fix.&amp;nbsp; That way you can test until you get it right without having to keep re-creating the input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want to count the number of delimiters then you should be able to do it by just reading and writing lines.&amp;nbsp; To remove the embedded line breaks just don't write end of line until you see the next record starting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First let's convert your example into an actual file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename source temp;
data _null_;
  file source ;
  put
 'col1£col2£col3£col4£col5'
/'myname£myaftername£myaddress£this is a text column'
/'wtih crlf all over'
/'the place £col5_account'
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So here is what it looks like:&lt;/P&gt;
&lt;PRE&gt;164  data _null_;
165    infile source ;
166    input ;
167    list;
168  run;

NOTE: The infile SOURCE is:
      Filename=.../#LN00024,
      Owner Name=XXX,Group Name=YYY,
      Access Permission=-rw-rw-r--,
      Last Modified=14Dec2019:13:05:57,
      File Size (bytes)=119

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6
1         col1£col2£col3£col4£col5 24
2         myname£myaftername£myaddress£this is a text column 50
3         wtih crlf all over 18
4         the place £col5_account 23
NOTE: 4 records were read from the infile SOURCE.
      The minimum record length was 18.
      The maximum record length was 50.&lt;/PRE&gt;
&lt;P&gt;Now let's run a data step to remove the breaks. This one will add a space where the line break was.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename target temp;
data _null_;
  infile source end=eof;
  file target ;
  input ;
  count=countc(_infile_,'£');
  if total+count &amp;gt; 4 then do ;
    put ;
    total = 0;
  end;
  if total then put ' ' @;
  total+count;
  put _infile_ @;
  if eof then put;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And here is the result:&lt;/P&gt;
&lt;PRE&gt;185  data _null_;
186    infile target ;
187    input ;
188    list;
189  run;

NOTE: The infile TARGET is:
      Filename=.../#LN00025,
      Owner Name=XXX,Group Name=YYY,
      Access Permission=-rw-rw-r--,
      Last Modified=14Dec2019:13:05:57,
      File Size (bytes)=119

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1         col1£col2£col3£col4£col5 24
2         myname£myaftername£myaddress£this is a text column wtih crlf all over the place £col5_account 93
NOTE: 2 records were read from the infile TARGET.
      The minimum record length was 24.
      The maximum record length was 93.&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2019 18:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611804#M178407</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-14T18:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611806#M178409</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually the result im trying to chive is the last three line of this test file attached, i know that there will be no crtl on the last column it is a number&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am extracting data from a system where some text is typed in by human and therefore can contain&amp;nbsp; linefeeds and carriage returns.&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>Sat, 14 Dec 2019 18:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611806#M178409</guid>
      <dc:creator>havmaage</dc:creator>
      <dc:date>2019-12-14T18:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611808#M178410</link>
      <description>&lt;P&gt;Your example does not seem consistent with 5 fields per record.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Do you have any control over how the values are dumped from the source?&amp;nbsp; If you can get the source to generate the file in a systematic way that it is possible to interpret it will make it much easier.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first line is the header row. And it looks like the the last 3 lines are normal records.&lt;/P&gt;
&lt;P&gt;But the stuff in the middle looks confused, they appear to be grouped in three lines per record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So lines 2 and 3 look like a record, but then line 4 looks like ii has just the last two fields, or two extra fields.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the other groups seem ok as they do not have that extra delimiter like line 3 does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;75    options ls=132;
76    data _null_;
77      infile source encoding='utf8' ;
78      input;
79      list ;
80    run;

NOTE: The infile SOURCE is:
      Filename=c:\downloads\testdata.txt,
      RECFM=V,LRECL=131068,File Size (bytes)=702,
      Last Modified=14Dec2019:13:50:36,
      Create Time=14Dec2019:13:50:35

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1         col1£col2£col3£col4£col5 24
2         simon£jespersen£højbovej£Dette er er fri tekst 46
3         med en masse£23  16
4         linieskift i£21 15
5         simon£jespersen£højbovej£Dette er er fri tekst 46
6         med en masse  13
7         linieskift i£20 15
8         simon£jespersen£højbovej£Dette er er fri tekst 46
9         med en masse  13
10        linieskift i£10 15
11        simon£jespersen£højbovej£Dette er er fri tekst 46
12        med en masse  13
13        linieskift i£07 15
14        simon£jespersen£højbovej£Dette er er fri tekst 46
15        med en masse  13
16        linieskift i£01 15
17        simon£jespersen£højbovej£Dette er er fri tekstmed en masse linieskift i£25 74
18        simon£jespersen£højbovej£Dette er er fri tekstmed en masse linieskift i£26 74
19        simon£jespersen£højbovej£Dette er er fri tekstmed en masse linieskift i£27 74
NOTE: 19 records were read from the infile SOURCE.
      The minimum record length was 13.
      The maximum record length was 74.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 19:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611808#M178410</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-14T19:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611813#M178412</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/257901"&gt;@havmaage&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of writing an output record in pieces, I find it easier to concatenate input lines to a SAS variable, until the expected number of delimiters is found, and then output and start building a new line. The following&amp;nbsp;simple code will work with any number of line breaks if the input follow these rules:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;all records are complete, so the number of pound signs is the same in every record,&lt;/LI&gt;
&lt;LI&gt;a full record never exceeds&amp;nbsp;32k, (about. 20 normal text pages),&lt;/LI&gt;
&lt;LI&gt;there is a always line break between records&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename source 'c:\temp\source.csv';
data _null_;
	file source ;
	put 'col1£col2£col3£col4£col5$';
	put 'myname£myaftername£myaddress£this is a text column';
	put 'wtih crlf all over';
	put 'the place £col5_account';
	put 'col1£col2£col3£col4£col5$';
	put 'myname£myaftername£myaddress£this is a text column';
	put 'with a single crlf £col5_account';
	put 'col1£col2£col3£col4£col5$';
 	put 'myname£myaftername£myaddress£this is a text column without crlf in the free text column £col5_account';
	put 'col1£col2£col3£col4£col5$myname£myaftername£myaddress£this is a text column without crlf in the free text column £col5_account';
  ;
run;

filename target 'c:\temp\target.csv';
data _null_;
	infile source;
	file target lrecl = 32000;
	retain outline;
	length outline $32000;
	input;
	outline = catx(' ',outline,_infile_);
	if countc(outline,'£') &amp;gt;= 8 then do;
		put outline;
		outline = '';
	end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;v.h.&lt;/P&gt;
&lt;P&gt;Erik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 21:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611813#M178412</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-12-14T21:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611816#M178415</link>
      <description>&lt;P&gt;The issue, as I see it, is that a&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;£&lt;/SPAN&gt; terminates the first 4 variables, while a CRLF terminates the last variable, correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, then if you assume&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;the fifth variable never starts with a CRLF, and&lt;/LI&gt;
&lt;LI&gt;the fifth variable never has an embedded CRLF&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename oneline temp;

data _null_;
  infile 'c:\temp\t.txt' ;
  length single_line $500;
  do until (n_dlim=4);
    input;
    n_dlim=sum(n_dlim,countc(_infile_,'£'));
    if char(single_line,length(single_line))^='£' then single_line=catx(' ',single_line,_infile_); else
    single_line=cats(single_line,_infile_);
  end;
  file oneline;
  put single_line ;
run;

data want;
  infile oneline dlm='£' truncover ;
  informat col1-col5 $char100. ;
  input col1 col2 col3 col4 col5 ;
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;Like your program it converts multiple lines into a single line with all 5 variables - i.e. it effectively removes the excess CRLF's.&amp;nbsp; It write the single line to a temporary raw file, which is read normally using the DLM=&lt;CODE class=" language-sas" style="color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;'£'&lt;/CODE&gt; delimiter.&amp;nbsp; A single line is considered complete when it has accommodated 4 &lt;CODE class=" language-sas" style="color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;£'&lt;/CODE&gt; signs.&amp;nbsp; This is why the program relies on the assumption that the fifth function has no leading or internal CRLF's (a trailing CRLF is of course, indicator of end-of-record).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One note:&amp;nbsp; If a&amp;nbsp;&lt;CODE class=" language-sas" style="color: #333333; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;'£'&lt;/CODE&gt; is immediately followed by a CRLF, I insert a blank in the concatenation of the accumulating single line and the record fragment represented by _INFILE_.&amp;nbsp; Otherwise just concatenate normally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can even do this in one step, by parsing the complete SINGLE_LINE text with a set of SCAN functions, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2 (keep=col:);
  infile 'c:\temp\t.txt' ;
  length single_line $500;
  do until (n_dlim=4);
    input;
    n_dlim=sum(n_dlim,countc(_infile_,'£'));
    if char(single_line,length(single_line))^='£' then single_line=catx(' ',single_line,_infile_); else
    single_line=cats(single_line,_infile_);
  end;
  col1=scan(single_line,1,'£');
  col2=scan(single_line,2,'£');
  col3=scan(single_line,3,'£');
  col4=scan(single_line,4,'£');
  col5=scan(single_line,5,'£');
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;
&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;OL&gt;
&lt;LI&gt;&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sat, 14 Dec 2019 21:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611816#M178415</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-12-14T21:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611882#M178448</link>
      <description>&lt;P&gt;Thank you very much,&amp;nbsp;&lt;/P&gt;&lt;P&gt;its funny on my computer it did not work by doing&amp;nbsp;count=countc(_infile_, '£');&amp;nbsp;&lt;/P&gt;&lt;P&gt;i needed to test on hex value&amp;nbsp;count=countc(_infile_,'A3'x );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But your solution seems to solve my problem, thank you very much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2019 15:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611882#M178448</guid>
      <dc:creator>havmaage</dc:creator>
      <dc:date>2019-12-15T15:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: count specific char in line and put linefeed at specific cnt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611912#M178457</link>
      <description>Your example file was using UTF8 encoding. So instead of 'A3'x you had a two byte sequence for that character.&lt;BR /&gt;You might have fewer issues if you used a standard ASCII character as the delimiter. Like TAB, '09'X, or pipe, '|'.&lt;BR /&gt;</description>
      <pubDate>Sun, 15 Dec 2019 19:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-specific-char-in-line-and-put-linefeed-at-specific-cnt/m-p/611912#M178457</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-15T19:45:49Z</dc:date>
    </item>
  </channel>
</rss>

