BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GiMaAsh
Calcite | Level 5
This used to work fine and now I keep getting the Expression using IN has components that are of different data types. I ran proc contents and confirmed Overall Rating and Begin date are both numeric. Not sure why I’m getting this error.

Proc sql;
Select Owner_name, count(distinct(varnum)) as number_low
From sheet1
Where Begin_date > input(‘10/28/2018’, mmddyy10.) and Overall_rating IN (‘1’, ‘2’, ‘’)
Group by owner_Name;
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

If Overall_Rating is numeric then you have your answer since '1' and '2' are character literals?

 

proc sql;
   select * from sashelp.class
   where age in ('14', '15')
   ;
quit;

 

Log:

 

28         proc sql;
29            select * from sashelp.class
30            where age in ('14', '15')
31            ;
ERROR: Expression using IN has components that are of different data types.
NOTE: The IN referred to may have been transformed from an OR to an IN at some point during PROC SQL WHERE clause optimization.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
32         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

If Overall_Rating is numeric then you have your answer since '1' and '2' are character literals?

 

proc sql;
   select * from sashelp.class
   where age in ('14', '15')
   ;
quit;

 

Log:

 

28         proc sql;
29            select * from sashelp.class
30            where age in ('14', '15')
31            ;
ERROR: Expression using IN has components that are of different data types.
NOTE: The IN referred to may have been transformed from an OR to an IN at some point during PROC SQL WHERE clause optimization.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
32         quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
GiMaAsh
Calcite | Level 5
So how would I just pull 0, 1, or 2 so it can be numeric?
GiMaAsh
Calcite | Level 5
Thank you for this! I finally got it
PaigeMiller
Diamond | Level 26

Show us the ENTIRE log for this PROC SQL. Showing us an error detached from the code doesn't usually help.

--
Paige Miller
ballardw
Super User

@PaigeMiller wrote:

Show us the ENTIRE log for this PROC SQL. Showing us an error detached from the code doesn't usually help.


Any bets that this new data was created with Proc Import and the result is one or more of the variables changing type.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 546 views
  • 0 likes
  • 4 in conversation