Cumulated multiplication ???

Cumulated multiplication ???

Post by Pawel Manowiec » Thu, 20 Jun 2002 07:24:15



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

Tnx,

Pawel Manowiecki
SAS Student

 
 
 

Cumulated multiplication ???

Post by Ya Hua » Thu, 20 Jun 2002 13:48:45


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

>Tnx,

>Pawel Manowiecki
>SAS Student


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.

HTH

Ya Huang

 
 
 

Cumulated multiplication ???

Post by Stig Ei » Thu, 20 Jun 2002 14:17:38


I think this will do the job:
data cpinew;
  set cpiold;
  retain cpicum 1;
  cpicum=cpicum*cpi;
run;

Stig Eide


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

> Tnx,

> Pawel Manowiecki
> SAS Student


 
 
 

Cumulated multiplication ???

Post by Xavier Autr » Thu, 20 Jun 2002 19:08:00


Hi Pawel,

Here s a simple solution:

data cpiold;
   input year cpi;
cards;
1999 100
2000 101
2001  99
2002  85
2003 120
;
run;

data cpinew;
  set cpiold;
  retain cpicum 1;
  i+1;
  cpicum=cpicum*cpi;
  cpiround=cpicum/100**(i-1);
  put cpicum= cpiround=;
run;

Xavier Autret


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

> Tnx,

> Pawel Manowiecki
> SAS Student


 
 
 

Cumulated multiplication ???

Post by Dorfman, Pa » Fri, 21 Jun 2002 01:50:49


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.
 
 
 

Cumulated multiplication ???

Post by Dale McLerr » Fri, 21 Jun 2002 04:54:31



Quote:> 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 ;

Or, equivalently using a DOW loop

data cumcpi ( keep = year cpi cumcpi ) ;
  prod=1;
  mult=1000 ;
  do until (lastrec);
    set cpi end=lastrec;
    mult   = mult * 0.01 ;
    prod   = prod * cpi  ;
    cumcpi =  0.1 * int (prod * mult) ;
    put cpi= cumcpi= ;
    output;
  end;
run ;

Dale

=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center

Ph:  (206) 667-2926
Fax: (206) 667-5977
---------------------------------------

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

 
 
 

Cumulated multiplication ???

Post by Dorfman, Pa » Fri, 21 Jun 2002 06:34:08




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

> Or, equivalently using a DOW loop

> data cumcpi ( keep = year cpi cumcpi ) ;
>   prod=1;
>   mult=1000 ;
>   do until (lastrec);
>     set cpi end=lastrec;
>     mult   = mult * 0.01 ;
>     prod   = prod * cpi  ;
>     cumcpi =  0.1 * int (prod * mult) ;
>     put cpi= cumcpi= ;
>     output;
>   end;
> run ;

Dale,

I am not sure what is the benefit of explicit looping in this case...
however, on the second thought, it could allow for saving a couple of
auxiliary variables :-)

data cumcpi ;
   do _iorc_ = 1000 by 0 ;
      set cpi ;
      _iorc_ = _iorc_ * 0.01 ;
      _n_    = _n_    * cpi  ;
      cumcpi =  0.1 * int (_n_ * _iorc_) ;
      put cpi= cumcpi= ;
      output ;
   end ;
run ;

Kind regards,
==================
Paul M. Dorfman
Jacksonville, FL
==================

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.

 
 
 

1. matrix multiplication in excel

What is the equivalent action to perform the Lotus123 matrix
multiplication

Premultiply     1   2    by     4   3   gives   8   5
                3   4           2   1           20  13

where all the elements are displayed on the worksheet?

In Excel, if I use =MMULT, I get only the first element of the matrix
displayed.

Thanks.

2. Win2k RAS problem - Can't route!

3. How to do Matrix Multiplication

4. did 80 min cds break my burner

5. Excel Matrix Multiplication

6. Me and my DLL problems again.

7. Excel97 matrix multiplication problem

8. Is it possible to use netmeeteing components in vb

9. Matrix Multiplication in Excel97

10. Matrix multiplication in Mac Excel?

11. wavelet transform and multiplication

12. Fast mod-2 multiplication needed