|
data have;
input type $14. count;
datalines;
critical 1
critical 2
non-critical 3
half-critical 4
half-critical 5
half-critical 6
non-critical 7
non-critical 8
critical 9
critical 10
half-critical 11
half-critical 12
;
run;
/****method 1:SQL****/
proc sql;
create table want as
select distinct type,
sum(count) as total
from have
group by 1
order by 2
;
quit;
/***method 2:data step****/
proc sort data=have;
by type;
run;
data want2 /*(drop=count)*/;
set have;
by type;
total+count;
if first.type then total=count;
*if last.type;
run;
both methods have their pros and cons
|