How can I extract the list of original variable names from a fvvarlist, i.e. a list of factor variables, possibly with interactions?
I need to do this for an ado file I'm writing so I want to be flexible enough to deal with various ways of expressing the fvvarlist. For example, maybe I have a varlist that looks like i.time##c.intensity or ib0.time##ib0.treatment. If I use fvunab I can separate out the interactions:
but what I want is to instead return a local with just the variable names, e.g. time intensity in the first example or time treatment in the second.
I thought about using subsintr() to remove # and rexexm() or strpos() to separate the prefixes that precede a "." (period) in the variable name, but given the many ways a fvvarlist can be expressed, there must be a more robust way to do this. One complication is that each space in the fvvarlist does not necessarily separate a variable; for example a valid fvvarlist would be i(0 1)b0.treatment i(1 2 3 4 5 6)bn.time i(0 1)b0.treatment#i(1 2 3 4 5 6)bn.time
Any ideas? Many thanks
I need to do this for an ado file I'm writing so I want to be flexible enough to deal with various ways of expressing the fvvarlist. For example, maybe I have a varlist that looks like i.time##c.intensity or ib0.time##ib0.treatment. If I use fvunab I can separate out the interactions:
Code:
. fvunab myfv : ib0.time##ib0.treatment
. di "`myfv'"
ib0.bimestre ib0.wave ib0.bimestre#ib0.wave
but what I want is to instead return a local with just the variable names, e.g. time intensity in the first example or time treatment in the second.
I thought about using subsintr() to remove # and rexexm() or strpos() to separate the prefixes that precede a "." (period) in the variable name, but given the many ways a fvvarlist can be expressed, there must be a more robust way to do this. One complication is that each space in the fvvarlist does not necessarily separate a variable; for example a valid fvvarlist would be i(0 1)b0.treatment i(1 2 3 4 5 6)bn.time i(0 1)b0.treatment#i(1 2 3 4 5 6)bn.time
Any ideas? Many thanks
Comment