要转换这段data step 为sql。
if substr(postal_code,1,1) in ('K','L','M','N','P') THEN PROVINCE='ON' ;
ELSE PROVINCE='XX';
想用下面when in (list of value)的方式但是报错:
ERROR: Operand of WHEN clause 1 is not the same data type as the CASE operand.
case substr(postal_code,1,1)
when in ('K','L','M','N','P') THEN 'ON'
ELSE 'XX'
END AS PROVINCE
目前成功的方式如下:
proc sql;
create table province as
select *,
case substr(postal_code,1,1)
when 'K' then 'ON'
when 'L' then 'ON'
when 'M' then 'ON'
when 'N' then 'ON'
when 'P' then 'ON'
ELSE 'XX'
END AS PROVINCE
FROM RATE ;
QUIT;