Hello,
Please review the code below.
For all the ALPHABETS in the column have_column I get below warning.
WARNING: INPUT function reported 'WARNING: Illegal first argument to function' while processing WHERE clause.
Please advise as to how can I avoid this warning.
/*There is an empty first row*/
data have;
input have_column $5.;
datalines;
00
02
06
08
10
24
29
30
39
NA
AB
CD
;RUN;
proc sql;
create table want as
select
have_column
from have
where input(have_column,best.)>=20
;quit;
What is it you want it to do when the character variable's value does not look like a character representation of a number? Note that SAS will treat numeric missing values as less than any actual number.
If you are trying to test if the string starts with characters like '21' or '3' or 'A' or 'b' that sort after the characters '20' then just do that:
where have_column > '20'
If are you trying to convert the string into a number and then test if it is larger than twenty you can use the ? modifier to the informat specification to suppress the notes.
where input(have_column,?32.)>=20
NOTE: BEST is the name of a FORMAT that tries to figure out the best way to display a number within the width specified. The concept does not make any sense for an INFORMAT as there is only one way to store any particular number, no matter how it is represented in the string being converted. If you use BEST as an informat SAS will just use the regular numeric infomat in its place.
What is it you want it to do when the character variable's value does not look like a character representation of a number? Note that SAS will treat numeric missing values as less than any actual number.
If you are trying to test if the string starts with characters like '21' or '3' or 'A' or 'b' that sort after the characters '20' then just do that:
where have_column > '20'
If are you trying to convert the string into a number and then test if it is larger than twenty you can use the ? modifier to the informat specification to suppress the notes.
where input(have_column,?32.)>=20
NOTE: BEST is the name of a FORMAT that tries to figure out the best way to display a number within the width specified. The concept does not make any sense for an INFORMAT as there is only one way to store any particular number, no matter how it is represented in the string being converted. If you use BEST as an informat SAS will just use the regular numeric infomat in its place.
You can avoid the WARNINGs in the log by
proc sql;
create table want as
select
have_column
from have
where input(have_column,? best.)>=20
;quit;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.