Could also do the following (if the intent is to produce a matrix), assuming ln_no exists on every row of the input data -- this eliminates the case statements entirely: proc sql; create table step_count as select ls_step_cd , sum (ls_step_cd = 'M17') as M17 , sum (ls_step_cd = 'K16') as K16 , sum (ls_step_cd = 'L39') as L39 , sum (ls_step_cd = 'L96') as L96 , sum (ls_step_cd = 'M60') as M60 , sum (ls_step_cd = 'L58') as L58 , sum ( ls_step_cd = 'L44') as L44 , sum (ls_step_cd = 'L52') as L52 /* everything else bucket -- results will vary if where clause is changed */ , sum (ls_step_cd not in ('M17', 'K16', 'L39', 'L96', 'M60', 'L58', 'L44', 'L52')) as X from lm_steps where ls_actual_compl_dt between &pmb and &pme and ls_step_cd in ('M17','K16','L39','L96','M60','L58','L44','L52') group by ls_step_cd order by ls_step_cd; quit;
... View more