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 |
urbain thierry YOGO <yogout@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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/

**Follow-Ups**:**st: Re: compute a variable with the same formula for each year***From:*"Joseph Coveney" <jcoveney@bigplanet.com>

- Prev by Date:
**Re: st: linesize with -sjlog-** - Next by Date:
**st: Bar chart** - Previous by thread:
**st: Manual calculation of scale factors after tobit and/or truncreg [econometrics help]** - Next by thread:
**st: Re: compute a variable with the same formula for each year** - Index(es):