Statalist


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

RE: st: calculation problem


From   steven proud <[email protected]>
To   <[email protected]>
Subject   RE: st: calculation problem
Date   Mon, 26 Nov 2007 21:31:07 +0000


OK, first of all, you need to set the time (panel) variable
tsset cs ts

Then, you could create
gen lagx=l1.x
gen changex=abs((x-lagx)/lagx)
gen lagchangex=l1.lagchangex
gen lag2changex=l2.lagchangex

gen y=(changex+lagchangex+lag2changex)/3

Yours,
Steven Proud
 

> Date: Mon, 26 Nov 2007 22:08:39 +0100
> Subject: st: calculation problem
> From: [email protected]
> To: [email protected]
>
> Dear friends, I need a little help to solve a calculation.
> I have a panel database (cs and ts), and for one variable, say "x", I need to calculate the following formula:
>
> y = summation_(i= t-2 to t) of (1/3)* abs[( x_i - x_i-1 )/ x_i-1 ]
>
> In other words, "y" is the three-year average variation in % of "x". I would get a new column for each firm-year data. Could anybody help me? Thanks in advance!
>
> D.
>
>
> *
> * 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/

_________________________________________________________________
Celeb spotting – Play CelebMashup and win cool prizes
https://www.celebmashup.com
*
*   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