|
you can use the _error_ variable for that:
data good bad;
infile ...;
input ....;
if _error_ then output bad;
else output good;
run;
That does not write the garbage data to the good dataset. However with
that method you don't have a good chance too see the reason for the
garbage. You only see the result (missing).
There are several methods to see also the reason. One could be to write
the content of the input buffer to a special (long) char-var, something
like:
data good(drop=_:) bad;
length _infile $100;
infile ...;
input ....;
_infile = _infile_;
if _error_ then output bad;
else output good;
run;
maybe also a good idea, to store the record-number:
...
_n = _n_;
...
All that does not show you the exact location, where the error occured.
Such things you see in the log.
Messages like:
invalid data for abc in column 17-19...
and a printout with the record, that error occured in. If you need that
für your analyze, you can store that log, e.g. with altlog option, or with
proc printto log=...
You there can retrieve your stored _N's and have a closer look into the
source.
If you want, you can also reduce the BAD dataset by something like:
bad(keep=_numeric_ _infile)
(only the numeric variables might be a problem...)
Gerhard
On Thu, 8 Jan 2009 09:00:37 -0800, Floyd Moseby <floydmoseby@GMAIL.COM>
wrote:
>I frequently work with large (1,000,000+ observations) raw text files
>that I import into SAS and store for querying. The text files are
>roughly 70 columns wide, and the informats are set during import.
>Occasionally SAS encounters garbage or corrupted observations that
>show invalid data (text in a numeric field, for example), usually as a
>result of input error at the source. These observations generate
>notes in the log, but don't break the import and simply generate
>missing values.
>
>I'd like to recapture and inspect some of this garbage data rather
>than bring it in with the clean stuff. Is there an option or method I
>can use to not only indicate observations containing invalid data, but
>to then write the offending observations to a separate table for my
>review? I just want a good/bad sorting method.
>
>Any ideas?
>
>Thanks in advance!
>
>Floyd
|