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: Create variable as a copy of a dynamically calculated second variable
From
"Wiemann, Markus" <[email protected]>
To
<[email protected]>
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/