How can I create a new column for an existing dataset that is the running total of an existing column - partitioned by some identifier?
ID | Value | New Val
In the data step this is accomplished with the sum statement
.
data want;
set have;
by id;
if first.id then running_total=0;
running_Total + value;
run;
In PROC SQL this would be impossible unless you have an ordering variable (in which you could do something like this):
proc sql;
create table want as
select id, value,
(select sum(value) from have V
where V.id=H.id and V.ordervar le H.ordervar
) as running_total
from have H
;
quit;
But SAS doesn't have a partition by
concept - the SAS data step is far more powerful than that.