Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoiding a SAS error message: "NOTE: Invalid argument to function INPUT"

Tags:

input

sas

Is there a way to test if a variable will fail the INPUT conversion process in SAS ? Or alternatively, if the resulting "NOTE: Invalid argument" message can be avoided?

data _null_;  
format test2 date9.;  
input test ;  
test2=INPUT(PUT(test,8.),yymmdd8.);  
if _error_ =1 then do;  
    _error_=0;  
    test2=INPUT(PUT(test-1,8.),yymmdd8.);  
end;  
put test2=;  
cards;  
20270229  
run;  
like image 506
Allan Bowe Avatar asked Feb 18 '09 17:02

Allan Bowe


1 Answers

Just include "??" before the format name. Your example has been modified below...

data null;
format test2 date9.;
input test ;
test2=INPUT(PUT(test,8.),?? yymmdd8.);
if error =1 then do;
error=0;
test2=INPUT(PUT(test-1,8.), ?? yymmdd8.);
end;
put test2=;
cards;
20270229
run;
like image 55
Jay Stevens Avatar answered Sep 28 '22 10:09

Jay Stevens