<?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: Reading Text File in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657433#M196996</link>
    <description>&lt;P&gt;Here is an alternative way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options compress=yes;
data have;
infile cards length=len;
input temp $varying2000. len;
if prxmatch('/^\d+\|\d+/',temp) then group+1;
cards;
1009|234|long description in comments
and need to be updated in the sas dataset.
Thank you for uploading data|264,00|345,09|address
1010|235|long description in comments
and need to be updated in the sas dataset|546.08|589|address
;

data temp;
length x $ 8000;
do until(last.group);
 set have;
 by group;
 x=cats(x,temp);
end;
drop temp;
run;
data want;
 set temp;
 a1=scan(x,1,'|');
 a2=scan(x,2,'|');
 a3=scan(x,3,'|');
 a4=scan(x,4,'|');
 a5=scan(x,5,'|');
 a6=scan(x,6,'|');
 drop x;
run;
&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Jun 2020 11:08:30 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-06-11T11:08:30Z</dc:date>
    <item>
      <title>Reading Text File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657209#M196967</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read the pipe delimited file in which one of the character column is having long description starting from line1 to line3 or line1 to line2.&amp;nbsp; I am unable to read this in sas dataset. Please help me to resolve the issue.&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;1009|234|long description in comments&lt;/P&gt;&lt;P&gt;and need to be updated in the sas dataset.&lt;/P&gt;&lt;P&gt;Thank you for uploading data|264,00|345,09|address&lt;/P&gt;&lt;P&gt;1010|235|long description in comments&lt;/P&gt;&lt;P&gt;and need to be updated in the sas dataset|546.08|589|address&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 07:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657209#M196967</guid>
      <dc:creator>Leonoids</dc:creator>
      <dc:date>2020-06-11T07:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657230#M196968</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Carriage-Return-Multiple-Line-Break-Issue-Importing-TXT-File/td-p/420988" target="_self"&gt;Carriage Return / Multiple Line Break Issue Importing TXT File &lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 07:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657230#M196968</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2020-06-11T07:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657261#M196971</link>
      <description>&lt;P&gt;You could read this with RECFM=N which means 'binary' so the datastep will continue reading across lines untill it reaches a delimiter.&amp;nbsp;&lt;BR /&gt;In your example it does not work fully because there seems to be a delimiter missing at the end of the third row, after "adress". If that line would end with a delimiter this simple datastep would do the trick:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 infile "c:\temp\file.txt" dlm="|" dsd recfm=N;
 input f1 : $10. f2 : $10. comments : $500. ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with this result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-06-11_100833.png" style="width: 436px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42637iF2F3B7A804BCD57E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-06-11_100833.png" alt="2020-06-11_100833.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I had to read all your data as characters since the numbers are not using decimal comma and dots consistently. Is that voluntary ?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657261#M196971</guid>
      <dc:creator>MCoopmans</dc:creator>
      <dc:date>2020-06-11T08:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657316#M196980</link>
      <description>&lt;P&gt;There is no delimiter at the end of the record.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 08:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657316#M196980</guid>
      <dc:creator>Leonoids</dc:creator>
      <dc:date>2020-06-11T08:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657429#M196993</link>
      <description>&lt;PRE&gt;options compress=yes;
data have;
infile cards length=len;
input temp $varying2000. len;
cards;
1009|234|long description in comments
and need to be updated in the sas dataset.
Thank you for uploading data|264,00|345,09|address
1010|235|long description in comments
and need to be updated in the sas dataset|546.08|589|address
;

data temp;
 set have;
 length x $ 8000;
 retain x;
 x=cats(x,temp);
 if countc(x,'|')=5 then do;output;call missing(x);end;
 drop temp;
run;
data want;
 set temp;
 a1=scan(x,1,'|');
 a2=scan(x,2,'|');
 a3=scan(x,3,'|');
 a4=scan(x,4,'|');
 a5=scan(x,5,'|');
 a6=scan(x,6,'|');
 drop x;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jun 2020 10:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657429#M196993</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-11T10:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657433#M196996</link>
      <description>&lt;P&gt;Here is an alternative way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options compress=yes;
data have;
infile cards length=len;
input temp $varying2000. len;
if prxmatch('/^\d+\|\d+/',temp) then group+1;
cards;
1009|234|long description in comments
and need to be updated in the sas dataset.
Thank you for uploading data|264,00|345,09|address
1010|235|long description in comments
and need to be updated in the sas dataset|546.08|589|address
;

data temp;
length x $ 8000;
do until(last.group);
 set have;
 by group;
 x=cats(x,temp);
end;
drop temp;
run;
data want;
 set temp;
 a1=scan(x,1,'|');
 a2=scan(x,2,'|');
 a3=scan(x,3,'|');
 a4=scan(x,4,'|');
 a5=scan(x,5,'|');
 a6=scan(x,6,'|');
 drop x;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jun 2020 11:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text-File/m-p/657433#M196996</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-11T11:08:30Z</dc:date>
    </item>
  </channel>
</rss>

