BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
smcelroy
Calcite | Level 5

I recieved ERROR: Expression using equals (=) has components that are of different data types. When all my variables in the statement are NUMERIC. I ran PROC CONTENTS to double check. Here is my Code:

proc sql;
create table birth_temp_hum as
select*
from birth_temp hum1
where birth_temp.dateofbirth=hum1.strdate and birth_temp.V001=hum1.DHSCLUST
order by birth_temp.CASEID;
quit;

Proc Contents results: From Hum1

Alphabetic List of Variables and Attributes# Variable Type Len Format Informat Label128312131415754610119
DHSCLUSTNum8BEST12.BEST32. 
FIDNum8BEST12.BEST32. 
MaxHumNum8   
_NAME_Char11  NAME OF FORMER VARIABLE
hm80Num8   
hm90Num8   
hm95Num8   
hm98Num8   
hum80percNum8BEST12.BEST32. 
hum90percNum8BEST12.BEST32. 
hum95percNum8BEST12.BEST32. 
hum975percNum8BEST12.BEST32. 
newstringChar11   
strdateNum8MMDDYY10.  
tempdateChar11   

Proc Content Results from birth_temp 

 34567891011121314151617185755566566676864636160626954
V000Char3  Country code and phase
V001Num4  Cluster number
V002Num4  Household number
V003Num3  Respondent's line number
V004Num4  Ultimate area unit
V005Num6  Women's individual sample weight (6 decimals)
V012Num3  Respondent's current age
V021Num4  Primary sampling unit
V022Num3  Sample strata for sampling errors
V023Num3  Stratification used in sample design
V024Num3  Region
V025Num3  Type of place of residence
V133Num3  Education in single years
V190Num3  Wealth index combined
V191Num6  Wealth index factor score combined (5 decimals)
V481Num3  Covered by health insurance
V501Num3  Current marital status
dateNum8DATE9.  
dateofbirthNum8MMDDYY10.  
dayNum8   
hw80Num8   
hw90Num8   
hw95Num8   
hw98Num8   
strdateChar11   
temp80percNum8BEST12.BEST32. 
temp90percNum8BEST12.BEST32. 
temp95percNum8BEST12.BEST32. 
temp975percNum8BEST12.BEST32. 
tempdateNum8   
yearNum8   
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@smcelroy wrote:

I recieved ERROR: Expression using equals (=) has components that are of different data types. When all my variables in the statement are NUMERIC. I ran PROC CONTENTS to double check. Here is my Code:

proc sql;
create table birth_temp_hum as
select*
from birth_temp hum1
where birth_temp.dateofbirth=hum1.strdate and birth_temp.V001=hum1.DHSCLUST
order by birth_temp.CASEID;
quit;
 

Your SQL FROM clause is essentially the problem here, not the where clause. It should say:

 

from birth_temp,hum1

with a comma between birth_temp and hum1.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

@smcelroy wrote:

I recieved ERROR: Expression using equals (=) has components that are of different data types. When all my variables in the statement are NUMERIC. I ran PROC CONTENTS to double check. Here is my Code:

proc sql;
create table birth_temp_hum as
select*
from birth_temp hum1
where birth_temp.dateofbirth=hum1.strdate and birth_temp.V001=hum1.DHSCLUST
order by birth_temp.CASEID;
quit;
 

Your SQL FROM clause is essentially the problem here, not the where clause. It should say:

 

from birth_temp,hum1

with a comma between birth_temp and hum1.

--
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
  • 1 reply
  • 1214 views
  • 1 like
  • 2 in conversation