Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Joseph Coveney" <jcoveney@bigplanet.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: compute a variable with the same formula for each year |

Date |
Fri, 12 Oct 2012 05:21:16 +0900 |

Urbain Thierry YOGO wrote: 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 -------------------------------------------------------------------------------- Would it be something like this? generate double a = 10 * exp(2 * (year - 1999)) Joseph Coveney * * 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/

**References**:**st: compute a variable with the same formula for each year***From:*urbain thierry YOGO <yogout@gmail.com>

- Prev by Date:
**st: Re: Bar chart** - Next by Date:
**Re: st: ordered logistic regression with endogenous variable** - Previous by thread:
**st: compute a variable with the same formula for each year** - Next by thread:
**st: Bar chart** - Index(es):