<?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 Reading multiples lines into one record from text file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiples-lines-into-one-record-from-text-file/m-p/814792#M321619</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Dear experts: &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have this issue, I have a text file with info like the following (unstructured data):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;Report Title
Report Subtitle
Dates, etc, etc
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
-------------------------------------------------------
A0100 Info about something
&amp;nbsp; &amp;nbsp; &amp;nbsp; important that is needed
&amp;nbsp; &amp;nbsp; &amp;nbsp; to capture
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
..................................................................&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The information I'm looking for is located after the "A0100" and continues for the next 2 lines ("Info about something important that is needed to capture"), sometimes it's 6 lines or 8 (it may vary) but the message always starts with the "A0100" and also starts at position 7 and ends at 31 and is needed in one field called "message" in one record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is another message below, it will be in another record (same field).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how to get this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FerV&lt;/P&gt;</description>
    <pubDate>Mon, 23 May 2022 20:33:50 GMT</pubDate>
    <dc:creator>japfvg</dc:creator>
    <dc:date>2022-05-23T20:33:50Z</dc:date>
    <item>
      <title>Reading multiples lines into one record from text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiples-lines-into-one-record-from-text-file/m-p/814792#M321619</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear experts: &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have this issue, I have a text file with info like the following (unstructured data):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;Report Title
Report Subtitle
Dates, etc, etc
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
-------------------------------------------------------
A0100 Info about something
&amp;nbsp; &amp;nbsp; &amp;nbsp; important that is needed
&amp;nbsp; &amp;nbsp; &amp;nbsp; to capture
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
..................................................................&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The information I'm looking for is located after the "A0100" and continues for the next 2 lines ("Info about something important that is needed to capture"), sometimes it's 6 lines or 8 (it may vary) but the message always starts with the "A0100" and also starts at position 7 and ends at 31 and is needed in one field called "message" in one record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is another message below, it will be in another record (same field).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how to get this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FerV&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 20:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiples-lines-into-one-record-from-text-file/m-p/814792#M321619</guid>
      <dc:creator>japfvg</dc:creator>
      <dc:date>2022-05-23T20:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiples lines into one record from text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiples-lines-into-one-record-from-text-file/m-p/814799#M321624</link>
      <description>&lt;P&gt;Read ahead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you can tell by looking at some part of the next line (or current line) that it is an continuation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case is looks like the continuation lines have blanks in the first field so perhaps something like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.txt' truncover end=eof;
  length id $5 rec 8 fullstring $300 ;
  input id $5 fullstring $100. ;
  do rec=1 by 1 until (eof or _infile_^=: '     ');
    if not eof then do;
      input @@ ;
      if _infile_ ^=: '     ' then do;
        input @6 nextstring $100.;
        fullstring=catx(' ',fullstring,nextstring);
      end;
    end;
  end;
  drop nextstring;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 May 2022 21:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiples-lines-into-one-record-from-text-file/m-p/814799#M321624</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-23T21:18:21Z</dc:date>
    </item>
  </channel>
</rss>

