Statalist


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

Re: st: Re: Forvalues not recognizing local macro


From   Anjali Gupta <aegupta@mail.utexas.edu>
To   "P. Wilner Jeanty" <pwjeanty@gmail.com>
Subject   Re: st: Re: Forvalues not recognizing local macro
Date   Sat, 22 Mar 2008 15:40:35 -0500

Thank you!

That must have been the problem - as there were no problems with COVAFS which
had no conditional statement.

I'll use COVAFS and add the 'if zboy == 0 ' with the reg statement.

Many thanks,
Anjali



*************
current e-mail:    aegupta@mail.utexas.edu
permanent e-mail:   anjgupta@alumni.indiana.edu
*************


Quoting "P. Wilner Jeanty" <pwjeanty@gmail.com>:

> On Sat, Mar 22, 2008 at 3:51 PM, Anjali Gupta <aegupta@mail.utexas.edu>
> wrote:
> > Hello,
> >
> > Thank you for the reply - however that didn't fix it.
> >
> > The code works fine if I take `covagrl' out of the forvalues loop.
> >
> > Anjali
>
> Another problem is that in the local `covagrl' you already have an <if
> exp>, so you cannot have two of these (<if zboy == 0> and <if _mult_
> == `j'>) for one command. That's why when you remove `covagrl' the
> program works. The problem is certainly not with the forvalues loop.
>
>
> >
> > *************
> > current e-mail:    aegupta@mail.utexas.edu
> > permanent e-mail:   anjgupta@alumni.indiana.edu
> > *************
> >
> >
> >
> > Quoting "P. Wilner Jeanty" <pwjeanty@gmail.com>:
> >
> > > On Sat, Mar 22, 2008 at 2:43 PM, Anjali Gupta <aegupta@mail.utexas.edu>
> > > wrote:
> > > > 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;
> > >
> > > Anjali, I am not sure exactly what causes your problem, but I suspect
> > > it has to do with where you place <if _mult_ == `j'> in your program,
> > > in which case INVALID SYNTAX would be legitimate. Try to modify your
> > > program as follows:
> > >
> > >  ........... e`covagrl'   if _mult_ == `j', robust cluster (sampleid)
> > >
> > >
> > > where ........ refers to anything that comes before e`covagrl'
> > >
> > > Best
> > > --
> > > P. Wilner Jeanty, Post-doctoral researcher
> > > Dept. of Agricultural, Environmental, and Development Economics
> > > The Ohio State University
> > > 2120 Fyffe Road
> > > Columbus, Ohio 43210
> > > (614) 292-6382 (Office)
> > > *
> > > *   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/
> > >
> >
> >
>
>
>
> --
> P. Wilner Jeanty, Post-doctoral researcher
> Dept. of Agricultural, Environmental, and Development Economics
> The Ohio State University
> 2120 Fyffe Road
> Columbus, Ohio 43210
> (614) 292-6382 (Office)
>

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