Help with data type error in my code (proc Sql)

#1
I have a simple code:

%let YYMMSD = 20160101;
%let YYMMED = 20160131;

proc sql;
select *
from table pol
where pol.date between &yymmsd and &yymmed
and pol.ID not in ('CA')
and pol.risk_state = 'CO';


I get an error "...Expression using equals (=) has components that are of different data types...." on the pol.risk_state line.

I already did a proc contents to make sure my I'm asking for the same format type, so I"m not surethe the issue is.

pol.date is a NUM type, so I'm asking it to get all date between 20160101 and 20160131
pol.ID is a Char type, so I"m asking it for 'CA'.
pol.risk_state is a Char type, and i"m asking for 'CO'.

what's my issue here?
 

noetsi

Fortran must die
#2
Usually you get this error when the data in the two fields is of different type, such as numbers stored as strings connecting to numbers as a numeric format in a join. It seems like pol.risk_state is the issue. When you look at the data does it look like they have two symbols in it (i.e., is it CO, CA etc)? You could try putting the term CO in " " rather than ' '.