|
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
>
|