Syntax, SELECT group:
SELECT <(select-expression)>;
WHEN-1 (when-expression-1<...,
when-expression-n>) statement;
<...WHEN-n (when-expression-1 <...,
when-expression-n>) statement;>
<OTHERWISE statement;>
END;
|
select (a); when (1) x=x*10; when (3,4,5) x=x*100; otherwise; end
data emps(keep=salary group); set sasuser.payrollmaster; length Group $ 20; select(jobcode); when ("FA1") group="Flight Attendant I"; when ("FA2") group="Flight Attendant II"; when ("FA3") group="Flight Attendant III"; when ("ME1") group="Mechanic I"; when ("ME2") group="Mechanic II"; when ("ME3") group="Mechanic III"; when ("NA1") group="Navigator I"; when ("NA2") group="Navigator II"; when ("NA3") group="Navigator III"; when ("NA1") group="Navigator I"; when ("NA2") group="Navigator II"; when ("NA3") group="Navigator III"; when ("PT1") group="Pilot I"; when ("PT2") group="Pilot II"; when ("PT3") group="Pilot III"; when ("TA1","TA2","TA3") group="Ticket Agents"; otherwise group="Other"; end; run;
when ("fa1") group="Flight Attendant I";
select (toy); when ("Bear") price=35.00; when ("Violin") price=139.00; when ("Top","Whistle","Duck") price=7.99; otherwise put "Check unknown toy: " toy=; end;
select; when (toy="Bear" and month in ('OCT', 'NOV', 'DEC')) price=45.00; when (toy="Bear" and month in ('JAN', 'FEB')) price=25.00; when (toy="Bear") price=35.00; otherwise; end;