BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
david27
Quartz | Level 8

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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.

david27
Quartz | Level 8
Thank You @Tom.

I am trying to convert the string into a number and then test if it is larger than twenty.
This solves the problem.
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1649 views
  • 1 like
  • 3 in conversation