Ya,
This will work, however bear in mind that you will have to directly read
about 0.5*N**2 records. Such a scheme will quickly become prohibitively
expensive: already at N=10000 (not a large file by any stretch of fancy),
you will have to read 50 million records directly (and out of sequence and
hence rebuffering at each i-loop iteration unless SASFILE is used - granted,
with N=10000 it is a distinct possibility). Thus single-pass approaches make
more performance sense, all the more that, as you of course realize, no
cumulative amount has to be recomputed from the beginning of the chain each
time a new link is acquired.
Now if I get what Pawel wants correctly, I would venture to offer:
data cpi ;
input year cpi ;
cards ;
1999 100
2000 101
2001 99
2002 85
2003 120
;
run;
data cumcpi ( keep = year cpi cumcpi ) ;
retain prod 1 mult 1000 ;
set cpi ;
mult = mult * 0.01 ;
prod = prod * cpi ;
cumcpi = 0.1 * int (prod * mult) ;
put cpi= cumcpi= ;
run ;
SAS log prints:
cpi=100 cumcpi=100
cpi=101 cumcpi=101
cpi=99 cumcpi=99.9
cpi=85 cumcpi=84.9
cpi=120 cumcpi=101.9
Kind regards,
==================
Paul M. Dorfman
Jacksonville, FL
==================
> This seems to be a good candidate for set point option:
> data xx;
> input year cpi;
> cards;
> 1999 100
> 2000 101
> 2001 99
> 2002 85
> 2003 120
> ;
> data xx;
> do i=1 to nobs;
> ncpi=1;
> do j=1 to i;
> set xx nobs=nobs point=j;
> ncpi=ncpi*cpi;
> end;
> output;
> end;
> stop;
> proc print;
> run;
> ----------------
> Obs i ncpi year cpi
> 1 1 100 1999 100
> 2 2 10100 2000 101
> 3 3 999900 2001 99
> 4 4 84991500 2002 85
> 5 5 10198980000 2003 120
> Is this what you want? The first few digits seem to match your
> result, not sure if I need some rounding.
> >On Tue, 18 Jun 2002 15:24:15 -0700, Pawel Manowiecki
> >I have CPI (Consumer price index) series
> >with the year before as a base.
> >(change in prices from the preceeding year)
> >for example :
> >1999 100
> >2000 101
> >2001 99
> >2002 85
> >2003 120
> >And i want to translate it in cumulated series.
> >CPI with a base period in 1999.
> >So i have got to multiplicate 1-with-2, 1-with-2-with-3,
> >and so on ...
> >so it is :
> >1999 100
> >2000 101
> >2001 99,9
> >2002 84,9
> >2003 101,9
> >How to do it in the simplest way in SAS ??
> >(Not using ln aproximation :-) )
Blue Cross Blue Shield of Florida, Inc., and its subsidiary and
affiliate companies are not responsible for errors or omissions in this e-mail message. Any personal comments made in this e-mail do not reflect the views of Blue Cross Blue Shield of Florida, Inc.