当我使用像这样的声明的案例时:
...
, case when majcat in (1,2,3,4,5) then "Inpatient"
when majcat in (3) then "IP-Surgical"
else "N/A" end as serv_cat
服务器没有将Inpatient和IP-Surgical分开,将它们组合在一起。为什么会发生这种情况?我该如何解决?
以下是上下文的完整代码:
proc sql;
create table raw_claims_summ as
select pcp_npi
, pcp_name
, practice_name
, rpt_cut_1
, rpt_cut_2
, sum(paid)
, sum(admits)
, sum(days)
, sum(units)
, case when majcat in (1,2,3,4,5) then "Inpatient"
when majcat in (3) then "IP-Surgical"
else "N/A" end as serv_cat
from raw_claims
group by 1,2,3,4,5,10
order by 1
;quit;
答案 0 :(得分:3)
您应该从第一个when
子句中删除3:
CASE WHEN majcat IN (1, 2, 4, 5) THEN "Inpatient"
-- 3 removed here ---^
WHEN majcat in (3) THEN "IP-Surgical"
ELSE "N/A"
END AS serv_cat