Renzo Comolli
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'[1] 
>>> This should work: 
if var2[1] == 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
falses. 
*
*   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/