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]

st: Generation of Variables with reference to values in the same column


From   Arnold Patrick Behrer <[email protected]>
To   [email protected]
Subject   st: Generation of Variables with reference to values in the same column
Date   Thu, 13 Sep 2012 23:40:00 -0600

Hello,

Is there an easy way to generate a variable that measures the change in a given column? Specifically I want to create a variable that is equal to:

 log(CPIt) - log(CPIt-1)

I tried using the following code:

generate log(CPI[2])-log(CPI[1])

But that simply filled the column with the results of the function using the values of CPI in rows 1 & 2. Short of doing that manually for each row, is there a way to write something like:

generate log(CPI[X]) - log(CPI[X-1])

That just goes down the column and calculates for each new row? Or should I just export into Excel?

Best,

Patrick


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