Proc sql
data have;
input OBS ID Grouper Paid VAR2 VAR3;
drop obs;
cards;
1 111 . 100 150 200
2 111 0 100 150 200
3 111 . 100 150 200
4 122 . 100 150 200
5 122 7 100 150 200
6 123 1 100 150 200
7 125 . 100 150 200
8 125 . 100 150 200
9 125 . 100 150 200
10 125 . 100 150 200
;
proc sql;
create table want as
select id,grouper,sum(paid) as s1,sum(var2) as s2, sum(var3) as s3
from
(select *, max( Grouper ne .) as k from have group by id having k=1)
group by id
having grouper>.
union all
select id,grouper,paid as s1, var2 as s2, var3 as s3
from (select *, max( Grouper ne .) as k from have group by id having k=0)
order by id;
quit;