使用case when和like语句编写SQL sas代码时出现语法错误

时间:2014-01-15 21:42:27

标签: sql function syntax-error sas sql-like

见下面的代码。对于特定行业,例如“Fss”有一个标题列表,变量作业标题必须与标题创建匹配。

   proc sql;
   create table ildp.ildp_1h_v5 as
   select industry,jobtitle,webpagesource,assetname,qtr,companyname,
   case 
   when industry = "FSS" and (jobtitle like 'CMO%' OR jobtitle like 'Chief Innovation)
   then 1
   else case when ..#continued.#

1 个答案:

答案 0 :(得分:2)

or like无效的SQL。试试这个:

proc sql;
create table ildp.ildp_1h_v3 as
select *,
       (case when industry = "FSS" and
                  (jobtitle like 'CIO%'
                   OR jobtitle like 'ChiefInnovation%' 
                   OR jobtitle like 'director%'
                   OR jobtitle like 'head%'
                   OR jobtitle like 'distribution%'
                   OR jobtitle like 'claims%'
                   OR jobtitle like 'VP%'
                   OR jobtitle like 'President%')
             then 1 else 0
        end) as title_flag
from ildp.ildp_1h_v2;

quit;