BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

I have this observations like this:

Testplace Method capacity
Testplace A Normal 1213
Testplace A Normal 1333

 

I need to sum up the capacity for testplace A so it becomes one line

testplace Method capacity
testplace A normal 2546

 

with proc sql?

1 REPLY 1
Shmuel
Garnet | Level 18

You can use any of next methods:

/* 1 */
proc summary data=have nway;
  class name method;
  var capacity;
  output out=want(drop _freq_ _type_) sum=;
run;

/* 2 */
proc sql;
  create table want as
  select testplace, method, sum(capacity) as capacity
 from have
 group by testplace, method;
quit;

/*3 */
proc sort data=have; by testplace method; run;
data want;
 set have;
  by testplace method;
      retain total;
      if first.method then total=0;
      total+capacity;
      if last.method then do;
         capacity=total;
         output;
      end;
run;