- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear experts:
I have this issue, I have a text file with info like the following (unstructured data):
Report Title
Report Subtitle
Dates, etc, etc
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
-------------------------------------------------------
A0100 Info about something
important that is needed
to capture
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
..................................................................
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.
If there is another message below, it will be in another record (same field).
Any ideas on how to get this?
Thanks in advance.
Kind regards!
FerV
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Read ahead.
As long as you can tell by looking at some part of the next line (or current line) that it is an continuation.
In your case is looks like the continuation lines have blanks in the first field so perhaps something like this.
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;