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, <Max.Livingston@ny.frb.org> 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/