用CASE WHEN...THEN ... END语句,case 语句可以嵌套。
例如:
[code:2ywa20ji]data a;
a=1;
b=0;
output;
a=2;
b=.;
output;
run;
proc sql;
create table b as
select a.a, a.b,
(CASE when b=. then
case when a=1 then 'a miss'
when a=2 then 'miss'
else ''
end
when b=1 then '1'
else ''
END) as test
from a;
quit;[/code:2ywa20ji]