Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: forvalues not recognizing local macro


From   "Vladimir Vakhitov" <[email protected]>
To   [email protected]
Subject   Re: st: forvalues not recognizing local macro
Date   Sat, 22 Mar 2008 17:36:36 -0400

Try -set trace on- command and run your loop again. Tracing will point
you to the place where the syntax error is made.

So far I see only one spot where the error could have happened:
-robust cluster (sampleid), if _mult_ == `j';-
Here, -if- statement should go before the options, because one of your
macros already has another -if- condition. Actually, it should be
something like

reg   actscaf3 efchmag3 famrotf3 posscaf3 negscaf3 acpscaf3 monscaf3
psyscaf3 e `covagrl'  & _mult_ == `j'  , robust cluster (sampleid);

I personally wouldn't mix variables and `if' conditions in the same macro.

Vladimir.


2008/3/22, Anjali Gupta <[email protected]>:
> Hello,
>
>  In the following examples, the MICOMBINE command recognizes my local varlist,
>  but the FORVALUES loop results in INVALID SYNTAX if I refer to the local macro.
>   Any help is much appreciated.
>
>  *****************************
>
>
>  local covafs
>        " zmale agecmof2   zblack zhispanc
>         zhchld1a   zxxwrkft zboy
>           zcurremp   zcar" ;
>
>
>  local covaboy
>        " zmale agecmof2   zblack zhispanc
>         zhchld1a   zxxwrkft zboy
>           zcurremp   zcar if zboy ==1 " ;
>
>  local covagrl
>         " zmale agecmof2   zblack zhispanc
>         zhchld1a   zxxwrkft zboy
>           zcurremp   zcar if zboy == 0" ;
>
>
>
>  * ATTEMPT TO REDEFINE COVAGRL WITHIN LOOP;
>
>  * 2 - PARENTING ONLY;
>  micombine reg   actscaf3
>  efchmag3
>  famrotf3
>  posscaf3
>  negscaf3
>  acpscaf3
>  monscaf3
>  psyscaf3
>         e       `covagrl'       ,impid(_mult_) obsid(sampleid)  robust cluster (sampleid) ;
>
>  forvalues j = 1/10 {;
>
>  local covagrl
>         " zmale agecmof2   zblack zhispanc
>         zhchld1a   zxxwrkft zboy
>           zcurremp   zcar if zboy == 0" ;
>
>   reg   actscaf3
>  efchmag3
>  famrotf3
>  posscaf3
>  negscaf3
>  acpscaf3
>  monscaf3
>  psyscaf3
>         e
>  `covagrl'
>
>         , robust cluster (sampleid), if _mult_ == `j';
>
>
>
>         local r2 =  e(r2);
>       gen obs`j' = `r2';
>
>  };
>
>  list  obs1-obs10 in 1/1;
>  drop obs1-obs10;
>
>  *********************************
>
>  * DESIRED METHOD - REFER TO COVAGRL DEFINED ABOVE;
>
>  * 3 - YOUTH ONLY;
>  micombine reg   actscaf3
>   stasclf3
>  pbsscaf3
>  extscaf3
>  innscaf3
>  frscaf3
>  hopscaf3
>  envscaf3
>         e       `covagrl'       ,impid(_mult_) obsid(sampleid)  robust cluster (sampleid) ;
>
>
>  forvalues j = 1/10 {;
>         qui reg actscaf3
>   stasclf3
>  pbsscaf3
>  extscaf3
>  innscaf3
>  frscaf3
>  hopscaf3
>  envscaf3
>         e       `covagrl'       , robust cluster (sampleid), if _mult_ == `j';
>
>
>
>         local r2 =  e(r2);
>       gen obs`j' = `r2';
>
>  };
>
>  list  obs1-obs10 in 1/1;
>  drop obs1-obs10;
>
>
>
>
>  *************
>  current e-mail:    [email protected]
>  permanent e-mail:   [email protected]
>  *************
>
>
>
>
>  *
>  *   For searches and help try:
>  *   http://www.stata.com/support/faqs/res/findit.html
>  *   http://www.stata.com/support/statalist/faq
>  *   http://www.ats.ucla.edu/stat/stata/
>


-- 
__________________
Volodymyr Vakhitov
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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