On Mon, 28 May 2012, Paolo Caliò wrote:
Hello!
I need to create some dummy variables in order to capture all
the possible
combinations of a certain set of variables.
[...]
Does this help?
<hansl>
function list CombinDums(list X)
scalar pwr = 1
series category = 0
loop foreach i X --quiet
category += pwr * (X.$i>0)
pwr *= 2
end loop
list ret = dummify(category)
return ret
end function
nulldata 32
set seed 1234
series a = normal()
series b = normal()
series c = normal()
list X = a b c
list D = CombinDums(X)
</hansl>
--------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti@univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
--------------------------------------------------
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users