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: compute a variable with the same formula for each year
From
urbain thierry YOGO <[email protected]>
To
[email protected]
Subject
st: compute a variable with the same formula for each year
Date
Thu, 11 Oct 2012 20:40:54 +0100
Hi all
I have a variable year going from 2000 to 2010. I want to compute the
following formula for each year a=10exp(2t). But the point is that i
need the respective observations to constitute a variable, not
independent scalar. I have tried the following code:
egen t=group(year)
forvalue t=1(1)11{
gen y`t'=10*exp(2*`t')
}
gen a=year
replace a=y1 if year==2000
replace a=y2 if year==2001
replace a=y3 if year==2002
.
.replace a=y11 if year==2010
Please is there a simple code to do this? thank you
--
*Urbain Thierry YOGO
Ph.D candidate in Economics*
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/