Date: Fri, 11 Jan 2008 10:57:15 -0600
Reply-To: "data _null_," <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_," <datanull@GMAIL.COM>
Subject: Re: cumulative sum with subgroups ?
In-Reply-To: <110d1b37-a034-4774-9f9d-5ac8b79d73f7@k2g2000hse.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
PROC FREQ with weight SUMNB.
data work.tst;
input id date nnb sumnb;
cards;
1 10 2 15
1 11 1 15
1 12 1 20
1 13 1 10
2 7 1 150
2 9 1 200
2 10 2 150
2 17 1 300
;;;;
proc freq;
by id;
tables date / list nopercent;
weight sumnb;
run;
On Jan 11, 2008 10:50 AM, ChrisG <chris.godlewski@gmail.com> wrote:
> Hi
>
> Suppose i have such dataset :
>
> id date nnb sumnb
> 1 10 2 15
> 1 11 1 15
> 1 12 1 20
> 1 13 1 10
> 2 7 1 150
> 2 9 1 200
> 2 10 2 150
> 2 17 1 300
>
> i would like sas to do the following thing in a additional variable,
> let call it cumsumnb :
>
> id date nnb sumnb cumsumnb
> 1 10 2 15 15
> 1 11 1 15 30
> 1 12 1 20 50
> 1 13 1 10 60
> 2 7 1 150 150
> 2 9 1 200 350
> 2 10 2 150 500
> 2 17 1 300 800
>
> in other words, to calculate in an 'incremental way' the cumulative
> sum of sumnb by date within the id subgroup ...
>
> i hope i was clear enough ...
>
> many thanks for any help !
>
> cheers
>
> CG
>
|