Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Tests on sums of coefficients?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Tests on sums of coefficients?
Date   Mon, 12 Jul 2004 19:51:52 +0100

Be very careful here. As numerous threads bear 
witness, looping around 

local testsum = "`testsum'+`var'"

will truncate your macro at some limit. It 
is much safer to copy, not evaluate: 

local testsum "`testsum'+`var'" 

Nick 
[email protected] 

Michael S. Hanson
 
> 	Answering my own question (after tearing out some more 
> hair first), 
> the following -- ultimately quite simple -- code seems to do 
> the trick. 
>   Improvements or alternatives are welcome.
> 
> 	. local testsum "0"
> 	. foreach var of varlist x* {
> 	. 	local testsum = "`testsum'+`var'"
> 	. }
> 	. test `testsum' = 0
> 

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