On Sat, Mar 22, 2008 at 2:43 PM, Anjali Gupta <[email protected]> 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/