Bookmark and Share

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: st: Create a 'rolling-mean' variable


From   "E. Paul Wileyto" <[email protected]>
To   [email protected]
Subject   Re: st: Create a 'rolling-mean' variable
Date   Thu, 04 Nov 2010 12:32:17 -0400

Try this (if you have no missings):

newvar=sum(oldvar)/_n

P

On 11/4/2010 12:17 PM, Léon Bueckins wrote:
Hi,

this might be a rather simple questions, but I don't get it to work, so help is appreciated.

I try to generate a variable that is simply the mean value of another up to this point in time, so a kind of rolling-mean. Example:

var_x | var_mean
1| 1/1
4 | 5/2
3 | 8/3
7 | 15/4
2 | 17/5

Regards,

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


--
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA  19104-3309

215-746-7147
Fax: 215-746-7140
[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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index