Hi!
I typed this data into Notepad, into a file called c:\temp\cr_blank.txt
[pre]
record 1 and even more stuff
still record 1
and this is also record 1
record2 record2 record2
more record2
guess what this is also record 2
and this too
just one line for record3
[/pre]
I made sure to put a carriage return at the end of every line and then put 1 hit of the space bar for my "blank" line separating each record.
Then, I used this program to read my file. You may have to change the logic a bit to read your file:
[pre]
data readraw (keep=record_num cntlines wholerec);
length wholerec $1000 inline $256;
retain wholerec record_num cntlines;
infile 'c:\temp\cr_blank.txt' length=lg end=eof ;
input @1 inline $varying. lg;
put lg= _infile_ ;
if _n_ = 1 then do;
cntlines = 0;
record_num=1;
end;
if lg gt 1 then do;
cntlines + 1;
wholerec = trim(wholerec)||' '||trim(inline);
end;
if inline = ' ' or lg eq 1 or eof then do;
output;
wholerec = ' ';
record_num + 1;
cntlines = 0;
end;
run;
ods listing close;
ods html file='c:\temp\readrec.html';
proc print data=readraw;
run;
ods html close;
[/pre]
The key is knowing that $varying. is an INFORMAT that you can use to read variable length records. When you use the LENGTH= option on your INFILE statement, SAS makes a variable (in this case, LG) that contains the "length" of the current record in the input buffer. So I don't have to worry about variable length records, because $varying allows SAS to read each "line". When I did the "put lg= _infile_;" statement, this is what I got in the log:
[pre]
lg=29 record 1 and even more stuff
lg=15 still record 1
lg=26 and this is also record 1
lg=1
lg=24 record2 record2 record2
lg=13 more record2
lg=33 guess what this is also record 2
lg=12 and this too
lg=1
lg=25 just one line for record3
lg=1
[/pre]
Notice how the "length" variable, LG, was 1 on every "blank" line that I had in my record. Even though I hit a Carriage Return (ENTER) key, I believe that it got translated to a space when SAS was reading the file or else it was treated as an "end of record" marker on my operating system (Windows).
You may have to fiddle with your LRECL= or the LENGTH statement for INLINE or WHOLEREC variables or with the logic of the code where the record is output, but I took a brute force approach and just concatenated every new "line" (represented by the INLINE variable) with the WHOLEREC variable and then only output the WHOLEREC variable with a "RECORD_NUM" variable and a CNTLINES variable -- CNTLINES represents the number of lines that went into making this new record.
There are probably some more elegant approaches, involving the use of the @@ to read the input or an explicit DO LOOP; however, I find that sometimes elegant code is harder to maintain and harder to explain.
If you try some variation of this technique and are still having problems, then your best bet is to contact Tech Support, because you could send them a copy of your input file on which they could test code. And they could collect any operating system information from you which may affect the kind of code that you need to write. To contact Tech Support, refer to:
http://support.sas.com/techsup/contact/index.html
Good luck,
cynthia