I am reading a field that can either be a packed numeric (PD2.) or an alpha character ($2.). Since I only care if it is a number, I am reading it as PD2. format. I know I can limit the number of error messages, but is there a way to suppress the message when it encounters a character value in this field?
since you are not interested in alpha character maybe is a good idea not to read those values (and by the way values are read with INFORMATS, with FORMATS you just print the values in a suitable way):
data test (drop=x);
infile datalines;
length x $2.;
input x @;
if ANYALPHA(x) then return;
else input @1 a 2.;
output;
datalines;
1234
e2
56446
hf
fy
5474
;
Also, with your INPUT statement (or with using the INPUT function), you can specify a "?" character ahead of the INFORMAT with some additional overhead.
THANKS everyone! The ?? worked... Also good to know about the ANYALPHA function -- I can think of a couple other programs where I which I had known about that one...
* use MIXED. to read "mixed data";
data test;
input x : mixed. @@;
datalines;
1234 e2 56446 hf fy 5474
;
run;
the LOG ... no errors ...
90 data test;
91 input x : mixed. @@;
92 datalines;
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.TEST has 6 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
the data set ...
Obs x
1 1234
2 .
3 56446
4 .
5 .
6 5474
for your data, you should be able to replace [10.] in the informat with [PD2.]