Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: New variable based on a sum of products of another variable


From   "Seamer Paul" <Paul.Seamer@westmidlands.nhs.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: New variable based on a sum of products of another variable
Date   Tue, 17 May 2011 12:45:00 +0100

Hi Statalisters

Any advice much appreciated,

I'm trying to create a new variable based on a sum of products covering a moving range of another variable,

I think this will be clearest if I use an example, 

I have a variable 'var2' and want to generate a new variable 'newvar' equal to a sum of products covering 
moving ranges of 'var2' (the values below are not significant, just wanted to keep it simple).

var2                       newvar 
2                           2
4                          (2*4) + 4
6                          (2*4*6) + (4*6) + 6
8                          (2*4*6*8) + (4*6*8) + (6*8) + 8
10                         (2*4*6*8*10) + (4*6*8*10) + (6*8*10) + (8*10) + 10
...                             ...



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index