data b;
set a;
array ss{*} ss1-ss6 (1 2 3 24 25 23);
array sc2 {*} $2. s1-s6;
do i=1 to 6;
if s=ss{i} then sc2{i}='p';
else sc2{i}='a';
end;
output;
drop ss1-ss6 i;
run;
proc sql;
create table c as
select *,count(t) as fred
from b
group by t,m;
quit;