Discussion:
End of file marker within infile data source
(too old to reply)
greg warnick
2005-02-16 19:43:07 UTC
Permalink
Hi SAS-L,

I have aflat file with ~500000 lines in it that I am reading in using
an infile statement. When SAS gets to line 325030, it stops reading
due to a Hex 1A (end of record marker?). I currently get around this
by opening the file in Textpad and doing a find/replace for this
character. I would prefer to do something in SAS. One thought was to
read both backward and forward, but since there are many of these pesky
Hex characters, I can't really know when the forward-read matches the
backward-read. Any suggestions or undocumented options in the infile
statement that would help passover these characters?

Thanks, Greg
greg warnick
2005-02-16 20:18:14 UTC
Permalink
Paul,

The IGNOREDOSEOF option on the infile statement took care of the
problem. Thanks for your assistance.

Greg
Choate,
2005-02-16 19:57:51 UTC
Permalink
Greg -

You are probably hitting a DOS end-of-file '1A0D'x or Ctrl-Z.

There is an option to let SAS read past it... "Options IgnoreDOSEOF;"


Otherwise you can read your file as a binary stream and locate the trouble
maker and replace it...

data _null_;
infile 'Test.txt' recfm=n;
input byte $char1. @;
if byte='1A'x then byte='20'x;
file 'fixed.txt' recfm=n;
put byte $char1. @;
run;

data _null_;
infile 'fixed.txt' recfm=n;
input byte $char1. @;
position+1;
hexbyte=put(byte,$hex2.);
put (_all_) (= );
run;

This sort of thing replaces all 'A1'x's which might be overkill!

Check out http://www.lookuptables.com/

hth

Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of greg
warnick
Sent: Wednesday, February 16, 2005 11:43 AM
To: SAS-***@LISTSERV.UGA.EDU
Subject: End of file marker within infile data source

Hi SAS-L,

I have aflat file with ~500000 lines in it that I am reading in using
an infile statement. When SAS gets to line 325030, it stops reading
due to a Hex 1A (end of record marker?). I currently get around this
by opening the file in Textpad and doing a find/replace for this
character. I would prefer to do something in SAS. One thought was to
read both backward and forward, but since there are many of these pesky
Hex characters, I can't really know when the forward-read matches the
backward-read. Any suggestions or undocumented options in the infile
statement that would help passover these characters?

Thanks, Greg

Loading...