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

Hi,

I am not able to merge two tables and getting below error. 

ERROR: Expression using equals (=) has components that are of different data types.

 

When i am checking contents of the variables its same for both.

LIBNAME MEMNAME MEMLABEL TYPEMEM NAME TYPE LENGTH VARNUM LABEL FORMAT FORMATL FORMATD INFORMAT INFORML INFORMD JUST NPOS
WORK MEMBER_CRMINT     cust_detail_ky 2 20 26     0 0   0 0 0 448
WORK CUSTOMER     cust_detail_ky 2 20 1     0 0   0 0 0 16

 

proc sql;
create table member_crmint(drop=med_cov_ind) as
select a.*,
b.subgrp_2_cd
from work.member_crmint a
left join work.customer b
on TRIM(LEFT(a.cust_detail_ky_char))=TRIM(LEFT(b.cust_detail_ky))
/* where a.med_cov_ind='Y'*/
;
quit;

 

Any help will be deeply appreciated.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

 

cust_detail_ky_charERROR: Expression using equals (=) has components that are of different data types.

So SAS thinks that the variables have different data types (one is numeric and one is character), and you have to figure out why SAS says this. You are trying to join on variable a.cust_detail_ky_char and b.cust_detail_ky

 

You have to look at the PROC CONTENTS output from both of these variables, but you have not shown us that. You are showing cust_detail_ky twice.

 

One might assume that cust_detail_ky_char is a character variable, based upon the name; but I hate to assume, it's really better if you find that information yourself and then decide what to do.

 

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

 

cust_detail_ky_charERROR: Expression using equals (=) has components that are of different data types.

So SAS thinks that the variables have different data types (one is numeric and one is character), and you have to figure out why SAS says this. You are trying to join on variable a.cust_detail_ky_char and b.cust_detail_ky

 

You have to look at the PROC CONTENTS output from both of these variables, but you have not shown us that. You are showing cust_detail_ky twice.

 

One might assume that cust_detail_ky_char is a character variable, based upon the name; but I hate to assume, it's really better if you find that information yourself and then decide what to do.

 

--
Paige Miller
Abhinav26
Obsidian | Level 7

There was a issue with case statement, sorry for bothering you guys. This is resolved.

PaigeMiller
Diamond | Level 26

@Abhinav26 wrote:

There was a issue with case statement, sorry for bothering you guys. This is resolved.


From now on, please show us the ENTIRE log for the step (PROC or DATA step) that has the error. Please do not show us error messages detached from the code, as it appears in the log. @Abhinav26 : We expect this 100% of the time from now on, thank you for helping us.

--
Paige Miller
ballardw
Super User

I notice in the post that there is no CASE statement but the OP says that was where the issue was.

 


@Abhinav26 wrote:

Hi,

I am not able to merge two tables and getting below error. 

ERROR: Expression using equals (=) has components that are of different data types.

 

When i am checking contents of the variables its same for both.

LIBNAME MEMNAME MEMLABEL TYPEMEM NAME TYPE LENGTH VARNUM LABEL FORMAT FORMATL FORMATD INFORMAT INFORML INFORMD JUST NPOS
WORK MEMBER_CRMINT     cust_detail_ky 2 20 26     0 0   0 0 0 448
WORK CUSTOMER     cust_detail_ky 2 20 1     0 0   0 0 0 16

 

proc sql;
create table member_crmint(drop=med_cov_ind) as
select a.*,
b.subgrp_2_cd
from work.member_crmint a
left join work.customer b
on TRIM(LEFT(a.cust_detail_ky_char))=TRIM(LEFT(b.cust_detail_ky))
/* where a.med_cov_ind='Y'*/
;
quit;

 

Any help will be deeply appreciated.

 

Thanks


 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 803 views
  • 0 likes
  • 3 in conversation