Hey Folks!
I've run into a situation where I'd like to build an expression which
contains different variables depending on the observation. Now, this
could be done by nesting a series of -cond()-s, though it would be a bit
complex (and hard to generalize).
Is there some way to use variables a pointers (use indirect evaluation of
the variables)? For example suppose that there were three variables:
bleen bling blam
ing 1 11
am 2 12
ing 3 13
ing 4 14
I'd like to be able to have
gen blob = eval("bl"+bleen), so that the dataset would then be
bleen bling blam blob
ing 1 11 1
am 2 12 12
ing 3 13 3
ing 4 14 4
where the (non-existant) -eval()- function takes its string argument and
interprets it as the name of a variable.
I vaguely recall being stumped by this once in the past, and know that
I'm stumped once again. Any tips would be much appreciated, even negative
ones.
Thanks,
Bill
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/