Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: loop over macros


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: loop over macros
Date   Mon, 23 Aug 2010 15:01:49 +0200

<> 

Your -macro-s are not variables, are they? Re loops, see NJC`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0005

*************
ma drop _all
sysuse auto, clear
local myvars1 price weight
local myvars2 length turn trunk
local model_1 "`myvars1'"
local model_2 "`myvars1' `myvars2'"

foreach macro in model_1 model_2{
logit foreign ``macro''
est save my`macro', replace
}
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jörg
Eulenberger
Gesendet: Montag, 23. August 2010 14:48
An: 'statalist@hsphsun2.harvard.edu'
Betreff: st: loop over macros

i want to loop over local macros, not over the items in the locals. I 
want to estimate 3 multinominal logit models. One with the variables in 
local macro "model_1" as independent variables in the model, one with 
the  variables in local macro "model_2" .....  and so on.  Only three 
Modells.

local set1_mig "migdummy1 migdummy2"
local set2_sex "fr49 fr48"
local set3_educ " schulart_e1 schulart_e2"


local model_1 "`set1_mig'"
local model_2 "`model_1' `set2_sex'"
local model_3 "`model_2' `set3_educ'"

foreach macro of varlist "`model_1'" "`model_2'" "`model_3'" {
mlogit  munomi7 `macro'
estimates save mlogit`macro'
  }
I cant find the right syntax for the foreach command.
Thanks in advance
*
*   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/


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index