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.
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;
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.
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.
@Bal23 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
would you please let me know how to
"Check what my substr() is returning" ?
Thanks.
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;
You have another post on this:
https://communities.sas.com/t5/Base-SAS-Programming/substract-input-etc/m-p/243273
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.