Bookmark and Share

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]

st: Create variable as a copy of a dynamically calculated second variable


From   "Wiemann, Markus" <m.wiemann@fs.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Create variable as a copy of a dynamically calculated second variable
Date   Thu, 9 Sep 2010 11:32:48 +0200

Hi everyone,

I am not sure whether the following is possible in Stata and, if yes,
how to address the problem.

I want to assign a new variable a value that is already stored in a
second variable. The problem is that I need a value of a variable that
is calculated dynamically. Let me explain it in a short example: Assume
I have the following variables:

FirstYear
Value2000
Value2001
Value2002
...
Value2010


What I need is something like 
. gen NewVariable = Value[String(FirstYear + 1)] 
that would read the value out of Value2006 if FirstYear had the value
2005. Is this possible in Stata? Would I need to write a macro for that?



Thanks and best regards
Markus



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index