<?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: Infile line return in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850951#M336294</link>
    <description>&lt;P&gt;Is your problem that you have end of line characters embedded into the value of one or more of the fields?&lt;/P&gt;
&lt;P&gt;The first thing to check is whether the inserted characters are the exact same as the characters that are actually being used to mark the ends of the lines.&amp;nbsp; If you are lucky the lines are ending with CR+LF (like a text file on Windows) and the inserted line breaks are using only CR or only LF.&amp;nbsp; &amp;nbsp;As a quick test read the file using different values of TERMSTR= infile option and see if the number of lines changes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'H:\DATA\Auto\test1.txt' termstr=crlf;
  input;
run;
data _null_;
  infile 'H:\DATA\Auto\test1.txt' termstr=lf;
  input;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it using TERMSTR=CRLF sees a few less lines than using TERMSTR=LF then the lines are ending with CRLF and the extra breaks are just bare LF characters.&amp;nbsp; So then use TERMSTR=CRLF on the INFILE statement and your code should work (although you should use TRUNCOVER instead of MISSOVER).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile 'H:\DATA\Auto\test1.txt' dsd dlm='|' truncover termstr=crlf firstobs=2 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that doesn't help then&amp;nbsp;check if the offending values have been quoted.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;Name|sex|car|track|circuit
Michael|M|ferr|se:2:laps|mugello
Loren|F|Yama|se:3:laps|Brno
Rosi|M|"Honda
accord"|se:15:Laps|Assen&lt;/PRE&gt;
&lt;P&gt;In which case you can just check to for matching quotes to determine if the the line break needs to be removed.&lt;/P&gt;
&lt;P&gt;(See this macro&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/replace_crlf.sas" target="_self"&gt;%replace_crlf()&lt;/A&gt;&amp;nbsp;for logic to copy the file to corrected file and let you replace the embedded LF or CR characters with something else)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you will need to count the number of delimiters seen.&amp;nbsp; Which might have trouble if the extra line breaks are in the last field on the line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'H:\DATA\Auto\test1.txt';
  file 'H:\DATA\Auto\test1_fixed.txt';
  input ;
  put _infile_ @;
  pipes+countc(_infile_,'|');
  if pipes &amp;gt;= 4 then do;
    put ;
    pipes=0;
  end;
  else put ' ' @;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Dec 2022 14:23:27 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-12-23T14:23:27Z</dc:date>
    <item>
      <title>Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850911#M336274</link>
      <description>&lt;P&gt;Need help to solve txt file&lt;/P&gt;&lt;P&gt;txt file&lt;/P&gt;&lt;P&gt;Name|sex|car|track|circuit&lt;BR /&gt;Michael|M|ferr|se:2:laps|mugello&lt;BR /&gt;Loren|F|Yama|se:3:laps|Brno&lt;BR /&gt;Rosi|M|Honda&lt;BR /&gt;|se:15:Laps|Assen&lt;BR /&gt;Marc|M|Isuzu&lt;BR /&gt;|se:20:Laps|Sentul&lt;BR /&gt;John Due|M|Mclaren|se:4:Laps|Mandalika&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;script&lt;/P&gt;&lt;P&gt;data WORK.test1 ;&lt;BR /&gt;infile 'H:\DATA\Auto\test1.txt' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2 ;&lt;BR /&gt;informat Name $8. ;&lt;BR /&gt;informat sex $7. ;&lt;BR /&gt;informat car $7. ;&lt;BR /&gt;informat track $6. ;&lt;BR /&gt;informat circuit $9. ;&lt;BR /&gt;format Name $8. ;&lt;BR /&gt;format sex $7. ;&lt;BR /&gt;format car $7. ;&lt;BR /&gt;format track $6. ;&lt;BR /&gt;format circuit $9. ;&lt;BR /&gt;input&lt;BR /&gt;Name $&lt;BR /&gt;sex $&lt;BR /&gt;car $&lt;BR /&gt;track $&lt;BR /&gt;circuit $&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to fix line break from text file&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yadiacho1_0-1671781858395.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78831i0A1E7E36C16D0E72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yadiacho1_0-1671781858395.png" alt="yadiacho1_0-1671781858395.png" /&gt;&lt;/span&gt;&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>Fri, 23 Dec 2022 07:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850911#M336274</guid>
      <dc:creator>yadiacho1</dc:creator>
      <dc:date>2022-12-23T07:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850913#M336275</link>
      <description>&lt;P&gt;Try to remove the MISSOVER and DSD options; the INPUT should then skip to the next line.&lt;/P&gt;
&lt;P&gt;If that does not fix it, some trickery involving _INFILE_ will be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 08:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850913#M336275</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-23T08:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850923#M336276</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;thanks, your solution Accepted. but in my real case can't solve it.&lt;/P&gt;&lt;P&gt;because there is missing value and some numbers and date. my column was shifting&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to solve it with _infile_ is there any reference on it. Thanks a lot&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 08:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850923#M336276</guid>
      <dc:creator>yadiacho1</dc:creator>
      <dc:date>2022-12-23T08:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850930#M336279</link>
      <description>&lt;P&gt;Try to provide sample data that are representative for your real data - ideally sample data that cover all the possible "patterns".&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 10:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850930#M336279</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-12-23T10:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850938#M336285</link>
      <description>&lt;P&gt;nah, wait. I need to mask confidential data. Maybe I will post another topic. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 12:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850938#M336285</guid>
      <dc:creator>yadiacho1</dc:creator>
      <dc:date>2022-12-23T12:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850951#M336294</link>
      <description>&lt;P&gt;Is your problem that you have end of line characters embedded into the value of one or more of the fields?&lt;/P&gt;
&lt;P&gt;The first thing to check is whether the inserted characters are the exact same as the characters that are actually being used to mark the ends of the lines.&amp;nbsp; If you are lucky the lines are ending with CR+LF (like a text file on Windows) and the inserted line breaks are using only CR or only LF.&amp;nbsp; &amp;nbsp;As a quick test read the file using different values of TERMSTR= infile option and see if the number of lines changes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'H:\DATA\Auto\test1.txt' termstr=crlf;
  input;
run;
data _null_;
  infile 'H:\DATA\Auto\test1.txt' termstr=lf;
  input;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it using TERMSTR=CRLF sees a few less lines than using TERMSTR=LF then the lines are ending with CRLF and the extra breaks are just bare LF characters.&amp;nbsp; So then use TERMSTR=CRLF on the INFILE statement and your code should work (although you should use TRUNCOVER instead of MISSOVER).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile 'H:\DATA\Auto\test1.txt' dsd dlm='|' truncover termstr=crlf firstobs=2 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that doesn't help then&amp;nbsp;check if the offending values have been quoted.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;Name|sex|car|track|circuit
Michael|M|ferr|se:2:laps|mugello
Loren|F|Yama|se:3:laps|Brno
Rosi|M|"Honda
accord"|se:15:Laps|Assen&lt;/PRE&gt;
&lt;P&gt;In which case you can just check to for matching quotes to determine if the the line break needs to be removed.&lt;/P&gt;
&lt;P&gt;(See this macro&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/replace_crlf.sas" target="_self"&gt;%replace_crlf()&lt;/A&gt;&amp;nbsp;for logic to copy the file to corrected file and let you replace the embedded LF or CR characters with something else)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise you will need to count the number of delimiters seen.&amp;nbsp; Which might have trouble if the extra line breaks are in the last field on the line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'H:\DATA\Auto\test1.txt';
  file 'H:\DATA\Auto\test1_fixed.txt';
  input ;
  put _infile_ @;
  pipes+countc(_infile_,'|');
  if pipes &amp;gt;= 4 then do;
    put ;
    pipes=0;
  end;
  else put ' ' @;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Dec 2022 14:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/850951#M336294</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-23T14:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Infile line return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/851102#M336369</link>
      <description>Thanks Guys, Its helpfull. I need to fix text and count the pipes.</description>
      <pubDate>Mon, 26 Dec 2022 04:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-line-return/m-p/851102#M336369</guid>
      <dc:creator>yadiacho1</dc:creator>
      <dc:date>2022-12-26T04:14:47Z</dc:date>
    </item>
  </channel>
</rss>

