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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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