The INPUT statement includes several modofiers which provide greater control of bad data issues when reading in raw data. The INPUT function will also accept the ?
or ??
modifier to suppress bad data messages in the LOG. e.g.
data test ; num = '2300231' ; output ; num = '0023' ; output ; num = '23*36' ; output ; num = '-3' ; output ; num = '+3' ; output ; num = '23e4' ; output ; run ; data test1 ; set test ; actual_num = input(num,10.) ; run ; data test2 ; set test ; actual_num = input(num,? 10.) ; run ; data test3 ; set test ; actual_num = input(num,?? 10.) ; put _all_ ; run ;
will generate the LOG:
38 data test1 ; 39 set test ; 40 actual_num = input(num,10.) ; 41 run ; NOTE: Invalid argument to function INPUT at line 40 column 18. num=23*36 actual_num=. _ERROR_=1 _N_=3 NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 40:18 42 43 data test2 ; 44 set test ; 45 actual_num = input(num,? 10.) ; 46 run ; num=23*36 actual_num=. _ERROR_=1 _N_=3 NOTE: There were 6 observations read from the data set WORK.TEST. NOTE: The data set WORK.TEST2 has 6 observations and 2 variables. 47 48 data test3 ; 49 set test ; 50 actual_num = input(num,?? 10.) ; 51 put _all_ ; 52 run ; num=2300231 actual_num=2300231 _ERROR_=0 _N_=1 num=0023 actual_num=23 _ERROR_=0 _N_=2 num=23*36 actual_num=. _ERROR_=0 _N_=3 num=-3 actual_num=-3 _ERROR_=0 _N_=4 num=+3 actual_num=3 _ERROR_=0 _N_=5 num=23e4 actual_num=230000 _ERROR_=0 _N_=6 NOTE: There were 6 observations read from the data set WORK.TEST. NOTE: The data set WORK.TEST3 has 6 observations and 2 variables.
From which we can see that both forms of the modifier suppress the NOTE: Invalid argument to function INPUT...
message. The ??
modifier also resets the automatic _ERROR_ flag to 0.