Your idea could be made to work like this:
gen variable_new = .
qui forval i = 1/`=_N' {
local var1 = var1[`i']
local var2 = var2[`i']
local var3 = var3[`i']
local var4 = var4[`i']
replace variable_new = cod_`var1'`var2'`var3'`var4' * sqrt(var5) in `i'
}
That's not going to be very fast, but it's perhaps more transparent than alternatives.
Nick
[email protected]
N.B. please send your winmail.dat to the list: see the FAQ.
Maria Dolores Montoya Diaz
I�m trying to make use of the combination of the values of four variables
(var1-var4) to identify another variable among a big list, which content
will be part of another operation. The situation is:
var1 var2 var3 var4 ... cod_0001 cod_0002
..... cod_1032
obs 1 1 0 3 2 ... 0.2435
0.5572 ..... 0.3453
obs 2 0 0 0 1 ... 0.0632
0.1023 ..... 0.5532
:
So, for obs 1, the variable selected will be cod_1032, for obs 2, cod_0001,
and so on. I need to do something like this:
gen variable_new = cod_`var1'`var2'`var3'`var4' * sqrt(var5)
*
* 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/