[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: How do I do -local macroname = var1 if var2==value
I would like to do the following thing
. local macroname = var1 if var2==value
This is not legal syntax though. I looked on [U] and [P]
to see if there were any extended macro function to help me
but I did not find any. I know for a fact that value referred
to in the if-condition is going always to be unique. I tried
the following work around but for some reason (that I don't
understand) it does not work either (it returns a missing even
if I know for a fact that it should return a number)
. tempvar var1
. gen `var1'=var1 if var2==value
. local macroname = `var1'
>>> This should work:
if var2 == value local macroname "var1"
But note that the test must be of a single value.
Stata can't cope with a variable-full of trues or
* For searches and help try: