Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Ignore this email


From   "Daniel H. Simon" <[email protected]>
To   [email protected]
Subject   st: Ignore this email
Date   Wed, 18 Oct 2006 19:06:53 -0400 (EDT)

Please ignore this question - I sent it before receiving Michael Blasnik's
nice solution. For some reason it didn't reach the list until now. Thanks
again to Michael.
Daniel

> A revision to my question: I can now see that creating X_AVG is not
> difficult, except for the case of multiple observations with the same
> date.
> However, I still need help to create X_AVG without using values of X that
> share the same date. Thanks. Daniel
>
> At 02:40 PM 10/18/2006 -0400, you wrote:
>>Hi  - I have data on a variable, X, for a set of individuals. Each
>>observation also has the date that X was recorded. I want to create a new
>>variable, X_AVG, which is the mean value of X for all observations with a
>>date that precedes the date for the current observation. X_AVG would be a
>>moving average, that would incorporate all observations with earlier
>> dates.
>>
>>Example:
>>
>>Obs     Date            X       X_AVG
>>1       1/1/2004        4       .
>>2       1/2/2004        3       4
>>3       1/4/2004        5       3.5
>>4       1/5/2004        2       4
>>5       1/8/2004        8       3.5
>>6       1/10/2004       5       4.4
>>7       1/10/2004       8       4.4
>>8       1/11/2004       3       5
>>
>>I want to know how to create X_AVG. And, in particular, is there a way to
>>deal with cases like observation 7, which has the same date as
>> observation
>>6. In that case, I would not want to use the value of X in observation 6
>>to create X_AVG for observation 7.
>>
>>I hope that this is clear enough. Thanks. Daniel
>>
>>*
>>*   For searches and help try:
>>*   http://www.stata.com/support/faqs/res/findit.html
>>*   http://www.stata.com/support/statalist/faq
>>*   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index