Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Subject: st: New variable based on a sum of products of  another variable
From 
 
"Clyde Schechter" <[email protected]> 
To 
 
[email protected] 
Subject 
 
Re: Subject: st: New variable based on a sum of products of  another variable 
Date 
 
Wed, 18 May 2011 07:21:57 -0700 
While you can probably do this by brute force, with some logarithmic help
for calculating products, if I understand what you want to do, it is
simpler and quicker to exploit the iterative relationship between
successive observations:
gen newvar = var2 in 1
replace newvar = var2*(newvar[_n-1] + 1)
Hope this helps.
Clyde Schechter
Associate Professor of Family & Social Medicine
Albert Einstein College of Medicine, Bronx, NY, USA
Please note new e-mail address: [email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/