Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Lim Lee <lee.haklim@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: problem with looping and saving macros |

Date |
Thu, 2 Feb 2012 15:35:31 -0500 |

Hey everyone, I've tried my best to look for answers on stata list but can't seem to why there's a break in my code to postfile means differences and pvalues of t-tests across variables by looping. The problem: there's a breakin my loopfile with the error "equation [__00000S] not found" occurring after a certain number of iterations. here's my code: local criteria `a' `b' `c' `d' `e' `f' `g' // where each letter itself is a macro corresponding to a list of variables (ex: `a' is local a age sex educ); tempfile descriptives tempname describe postfile `describe' str20 variable control_r4 control_r3 beneficiary_r4 beneficiary_r3 diff pvalue using `descriptives' foreach x of local criteria { svy: mean `x'4r, over(beneficiary) matrix meanr4=e(b) local mean1=meanr4[1,1] local mean3=meanr4[1,2] svy: mean `x'3r, over(beneficiary) matrix meanr3=e(b); matrix subn=e(_N) local mean2=meanr3[1,1]; local mean4=meanr3[1,2] tempvar change`x' gen `change`x''=`x'4r-`x'3r capt svy: mean `change`x'', over(beneficiary) gen name="`e(over_namelist)'" split name, parse("") gen(name) local name1=name1 local name2=name2 di " `name1' " di " `name2' " drop name* !!!---this is where the error "equation [__00000S] not found" occurs after numerous iterations--!!! lincom [`change`x'']`name1' - [`change`x'']`name2' local diff=r(estimate) local pvalue=2*ttail(r(df),abs(r(estimate)/r(se))) post `describe' ("`x'") (`mean1') (`mean2') (`mean3') (`mean4') (`diff') (`pvalue') } postclose `describe'; I know this error is not due to the local varlists because if the error occurs during a certain variable in `f ' and i redo the entire loop using just `f', there is no problem. I think the break happens after values for 31 variables are posted. The break also occurs if i separate the variables and run the loop files for each variable list. I've read in previous posts that there is no limit on the number of macros so I'm not entirely sure why there is a break. Though modifications are need, this loopfile command works in auto.dta. I'm using Stata 12.0 for Windows (32-bit) Revision 26 July 2011. Thanks in advance. Lim * * 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/

- Prev by Date:
**st: qnorm and ttest question** - Next by Date:
**st: RE: Calculating the shortest distances between observations (based on longitude and latitude)** - Previous by thread:
**st: qnorm and ttest question** - Next by thread:
**st: RE: Calculating the shortest distances between observations (based on longitude and latitude)** - Index(es):