Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How do I do -local macroname = var1 if var2==value-


From   "Renzo Comolli" <[email protected]>
To   <[email protected]>
Subject   st: How do I do -local macroname = var1 if var2==value-
Date   Fri, 16 Apr 2004 20:59:13 -0400

Dear Statalist

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]


Any suggestion would be appreciated.

Best Regards,
Renzo Comolli


*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index