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

RE: st: Multiple tests


From   "Ronnie Babigumira" <ronnie.babigumira@ios.nlh.no>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Multiple tests
Date   Fri, 4 Apr 2003 15:04:25 +0200

Thanks Nick, I now rest my case. To wrap up this thread

***My problem
automating (after regress)

test avgspring = deltaspring
test avgcrsgpa = deltacrsgpa, accum
.
.
.
test avgfrstsem  = deltafrstsem, accum


**Ernests Solution (if spring, crsgpa and all other suffixes are in the
varlist)
local i=0
foreach origvars of varlist spring crsgpa frstsem  {
          if `i'==0 test avg`origvars' = delta`origvars'
          else         test avg`origvars' = delta`origvars' , accum
          local i = `i' + 1
}

** Nicks solution (if not in varlist)
foreach origvars in spring crsgpa frstsem  {

We can also extract suffixes from a varlist with the same stub.

foreach v of var avg* {
	local V : subinstr local v "avg" ""
	local suff "`suff'`V' "
}

Now build up the tests:

local i = 0
foreach s of local suff {
	if `i++' == 0 test avg`s' = delta`s'
	else test avg`s' = delta`s', accum
}

Note how the incrementation of local macro i is performed in place (stata8)

Ronnie

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