Summing Rows of data where Key is the same

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Summing Rows of data where Key is the same

I need some assistance with using what I think is an index with aggregation of data. For each row that has the same key(NUM and ITEM), I want to add certain columns(Total and Qty) and group by the others. For example:

NUM     Total     Qty       Item

001       50.00     2          5

001       25.00     1          5

005       10.00     1          12

006       15.00     2          2

006         3.00     1          2

006         5.00     1          3

The output desired would be

NUM     Total     Qty     Item

001       75.00     3        5

005       10.00     1       10

006       18.00     3       2

006         5.00     1      3

Thanks in advance for your help.


Accepted Solutions
Solution
‎05-11-2015 05:53 PM
Super User
Posts: 10,538

Re: Summing Rows of data where Key is the same

Proc Means or Summary would probably be easiest:

proc summary data=have nway;

class NUM ITEM;

var Total Qty;

output out=want (drop=_type_ _freq_) sum=;

run;

View solution in original post


All Replies
Solution
‎05-11-2015 05:53 PM
Super User
Posts: 10,538

Re: Summing Rows of data where Key is the same

Proc Means or Summary would probably be easiest:

proc summary data=have nway;

class NUM ITEM;

var Total Qty;

output out=want (drop=_type_ _freq_) sum=;

run;

New Contributor
Posts: 2

Re: Summing Rows of data where Key is the same

Thanks for the quick reply, this worked as I hoped it would.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 241 views
  • 0 likes
  • 2 in conversation