Bookmark and Share

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]

st: macro of macros?


From   Maria Ana Vitorino <[email protected]>
To   <[email protected]>
Subject   st: macro of macros?
Date   Sun, 6 Nov 2011 10:01:39 -0500

Dear statalist users,
I've only recently started experimenting with macros and I have the following question: can we have a macro of macros and loop through the different sub-macros without having to set beforehand how many sub- macros there are in the macro? Maybe it's easier to understand what I'm looking for with an example:

I know that the following can be done:

local set1 "x1 x2"
local set2 "x2 x3"
local sets ""`set1'" "`set2'""  ***

foreach xvars of local sets {
reg y xvars
}

But, instead of having to list all the macros in the line ***, can we have something like:

local set1 "x1 x2"
local set2 "x2 x3"

local sets ""`set'*""

foreach xvars of local sets {
reg y xvars
}


Ideally I would like to add (or remove) sets as a please so I wouldn't like to have to keep updating the line *** everytime I do so...

Any suggestions are appreciated.

thanks,
Ana
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index