Statalist


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

Re: st: problem with macro in a loop


From   Tirthankar Chakravarty <[email protected]>
To   [email protected]
Subject   Re: st: problem with macro in a loop
Date   Wed, 10 Jun 2009 08:33:48 +0100

<>

Use -local-s.

/* begin */
sysuse auto, clear
local M_1 "gear_ratio displacement turn"
local M_2 "length weight trunk"
local M_3 "headroom rep78 mpg"

forv i=1/3 {
	logit foreign `M_`i''
	estimates store logit_M_`i' , title(M_`i')
}
/* end */

On Wed, Jun 10, 2009 at 8:20 AM, Leila Ben Aoun<[email protected]> wrote:
> Hi,
>
> I have a problem because I have many variables to put in my regression
> and with an excel file I have managed to prepare all the combination I
> want to put in my logistic regression. I named all my "X" in global
> macros such as M_1 M_2 .. M_150
> global  M_149   "level_0 level_1 level_2 level_3  skill_50pct
> marche_national emp20_49 emp50_99
> emp100etplus    nace17_1        nace17_2        nace17_3        "
> global  M_149   "scale_ICT_internet int_emp07  skill_50pct
> marche_national emp20_49 emp50_99
> emp100etplus    nace17_1        nace17_2        nace17_3        "
> global  M_150   "scale_ICT_internet int_emp07_d  skill_50pct
> marche_national size size2 nace17_1 nace17_2    nace17_3        "
>
> but then :
>
> local i = 1
> while `i'<177 {
>        logit  Y  $M_`i'
>        estimates store logit_M_`i' , title(M_`i')
>        local i = `i'+1
>        }
>
> it doesn't work ! How can I deal with this? The problem is $M_1 in my
> loop is only recognized as 1 but if I put $M_1 it works. But I don't
> to copy paste at least 150 times !
> Thanks for your help
>
> --
> Leila
> *
> *   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/
>



-- 
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index