如何将proc sql case caseement代码转换为数据步骤

时间:2018-12-21 13:14:31

标签: sas

我在proc SQL中有以下代码,我想将case语句移至数据步骤。

    Proc SQL;
    select 
    Xas,
    Yas,
case when missing(prj_role_desc) eq 1 then 'Unknown' else prj_role_desc end as prj_role_desc,
    case when job_descr eq 'X' or project_status in ('Open', 'Filled', 'Pending') then 'TB'end as tb_status
    from employee;
    quit;

1 个答案:

答案 0 :(得分:1)

您有两个case语句。

    data pies;
      set employee;
      if missing(prj_role_desc) then prj_role_desc='Unknown';
      if job_descr eq 'X' or project_status in ('Open', 'Filled', 'Pending') 
        then  tb_status='TB'
      keep Xas Yas prj_role_desc tb_status;
    run;