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]

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


From   "Clyde Schechter" <clyde.schechter@einstein.yu.edu>
To   statalist@hsphsun2.harvard.edu
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: clyde.schechter@einstein.yu.edu

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


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