The SAS Output Delivery System and reporting techniques

Invalid argument to function INPUT

Accepted Solution Solved
Reply
Super Contributor
Posts: 336
Accepted Solution

Invalid argument to function INPUT

 

I saw a note, "Invalid argument to function INPUT"  on the log based on my sas code:

 

var1=input(substr(var2,1,3), 8.);

 

It shows that:

 

Mathematical operations could not be performed at the following places. The results of the
operations have been set to missing values.

 

Would anybody explain how it will affect my results? How to fix it?

Thanks.

 

 


Accepted Solutions
Solution
‎01-13-2016 01:52 PM
Super User
Posts: 17,949

Re: Invalid argument to function INPUT

Create a new variable that is only the substr function, what you're using in the input() function. Then run a proc freq on that. Consider what the input() function is expecting and visually examining your data should give you a clear view of what's causing the issue. 

data check;
set have;
var_check=substr(var, 1, 3);
run;

proc freq data=check;
table var_check;
run;

 

View solution in original post


All Replies
Super User
Posts: 17,949

Re: Invalid argument to function INPUT

The note will also give you the record number of where the issue occurred so you can check your actual data.

 

It means that var1 will be set to missing when the substr() function does not return a valid value. Check what your substr() is returning and decide if you need to deal with those cases or if setting it to missing is fine. 

 

A general rule is to not allow notes like that in your log though, because it makes error checking later on difficult.

Super Contributor
Posts: 336

Re: Invalid argument to function INPUT

Thank you. How to find how much missing data it generates?

 

WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.

Super User
Posts: 10,549

Re: Invalid argument to function INPUT


wenling wrote:

Thank you. How to find how much missing data it generates?

 

WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.


The number of records with the error message are determined by the SAS system option Errors. You can change that by using code:

options errors=50;

 

The default is usually 20. Look at the results of the first 20 errors and see if you can identify the pattern of values that are causing the error.

Is the variable VAR1 text or numeric? Are there any characters in the first 3 of Var1 that are not numerals or decimal?

You will get that error if VAR1 has a value like "1 3245" or 1_234

 

Super Contributor
Posts: 336

Re: Invalid argument to function INPUT

would you please let me know how to

 

"Check what my substr() is returning" ?

 

 

Thanks.

Solution
‎01-13-2016 01:52 PM
Super User
Posts: 17,949

Re: Invalid argument to function INPUT

Create a new variable that is only the substr function, what you're using in the input() function. Then run a proc freq on that. Consider what the input() function is expecting and visually examining your data should give you a clear view of what's causing the issue. 

data check;
set have;
var_check=substr(var, 1, 3);
run;

proc freq data=check;
table var_check;
run;

 

Super User
Super User
Posts: 7,430

Re: Invalid argument to function INPUT

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 902 views
  • 0 likes
  • 4 in conversation