I would like to know if it is possible to execute multiple assignments as a consequence of a single CASE. That is, instead of having two CASE statements, have a single CASE statement with a 'then-do-end' like structure.
For example, how would I assign values to thing1
and thing2
based on x
within a single CASE statement?
data example;
input x $;
datalines;
A
A
A
B
B
;
run;
proc sql;
create table make_two_from_one as
select *
, case
when x = 'A' then 'Result1A'
when x = 'B' then 'Result1B'
else 'Error'
end as thing1
, case
when x = 'A' then 'Result2A'
when x = 'B' then 'Result2B'
else 'Error'
end as thing2
from example
;
quit;