Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Is there a way to tell if a local macro contains a particular value
From
[email protected]
To
[email protected]
Subject
Re: st: Is there a way to tell if a local macro contains a particular value
Date
Mon, 24 Dec 2012 13:19:18 -0500
Thanks!
I never realized that the extended macro functions could be used without
directly assigning their output to a macro. Interesting...
Max
Max Livingston
Research Analyst
Microeconomic Studies
Research and Statistics Group
Federal Reserve Bank of New York
(212) 720-7894
From: Nick Cox <[email protected]>
To: [email protected],
Date: 12/24/2012 12:01 PM
Subject: Re: st: Is there a way to tell if a local macro contains a
particular value
Sent by: [email protected]
Yes. See -help macrolists-.
. sysuse auto
(1978 Automobile Data)
. unab m_all : m*
. local make "make"
. local in : list make in m_all
. di `: list make in m_all'
1
. mac li
<other stuff>
_in: 1
_make: make
_m_all: make mpg
In your case
foreach v of var var1-var6 {
if `: list v in myvars' di "`v' is in the list"
else di "`v' is not"
}
Nick
On Mon, Dec 24, 2012 at 4:34 PM, <[email protected]> wrote:
> Say I have a local macro with a list of variable names: local myvars
var1
> var3 var5.
>
> Now say I'm iterating over all my variables (var1-var6), and want to do
> something if the variable is in `myvars.' Is there a simple way to
> determine this?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
This e-mail message, including attachments, is for the sole use of the intended recipient(s) and may contain confidential or proprietary information. If you are not the intended recipient, immediately contact the sender by reply e-mail and destroy all copies of the original message.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/