Help using Base SAS procedures

Recognizing one variable, then sum in another row

Reply
Contributor
Posts: 43

Recognizing one variable, then sum in another row

Hi. I have a dataset that looks like this..

Name Value
X 13
X 12
Y 44
X 12
Y 213
Z 12
Y 54

But.. it's with approximatly 2000 different X,Y,Z....

So what i would like SAS to do, is to recognize each specific X, and everytime it does so, add the "Value" variable. X would in this test case be 13+12+12 = 27 - output would thus look like:

Name Value
X 27
Y 311
Z 12

I've tryed to google it, but with no luck.

Any ideas?

Thanks!
Contributor
Posts: 43

Re: Recognizing one variable, then sum in another row

I think i just made this work:


proc sql;
create table g as
select
by,
sum(VALUE) as branch_profit
from c
where by ne ' '
group by NAME;
quit; Message was edited by: TMorville
Valued Guide
Posts: 2,175

Re: Recognizing one variable, then sum in another row

> Hi. I have a

> variable. X would in this test case be 13+12+12 = 27

challenging ;-)


> Any ideas?


proc means
will also provide class totals like
proc means data= whatever nway ;
class name ;
var value ;
output sum= out= summary ;
run ;
proc print ;
id name ;
var value ;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 79 views
  • 0 likes
  • 2 in conversation