Statalist


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

st: forvalues not recognizing local macro


From   Anjali Gupta <aegupta@mail.utexas.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: forvalues not recognizing local macro
Date   Sat, 22 Mar 2008 13:43:06 -0500

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:    aegupta@mail.utexas.edu
permanent e-mail:   anjgupta@alumni.indiana.edu
*************




*
*   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