Statalist


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

Re: st: cycling paired t test (and signed rank sum test)


From   n j cox <n.j.cox@durham.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: cycling paired t test (and signed rank sum test)
Date   Sun, 21 Oct 2007 21:14:53 +0100

Diego uses double quotes " " in defining his arrays.
As mentioned recently, in
<http://www.stata.com/statalist/archive/2007-10/msg00307.html>,
" " are not cosmetic but bind tighter than spaces separate.

Thus to Stata, "a1 b1 c1" is all _one_ word, or token. Thus, first time
around the loop, Diego is trying to execute

ttest a1 b1 c1 = a2 b2 c2

which is illegal.

The semi-colons don't perform any distinctive function
here, and, unless Diego is using Stata 6 or earlier, he is
better off with -forval-. So, Diego's code could be rewritten as

local array1 a1 b1 c1
local array2 a2 b2 c2
local n : word count `array1'
forval i = 1/`n' {
local var1 : word ‘i' of ‘array1'
local var2 : word ‘i' of ‘array2'
ttest `var1' = `var2'
}

Nick
n.j.cox@durham.ac.uk

Diego Bellavia

[...] I tried to implement arrays, and I ended up with something like

#delimit ;

local array1 "a1 b1 c1";
local array2 "a2 b2 c2";

local i = 1 ;

local n : word count `array1' ;

while `i' <= `n' {;

local var1 : word ‘i' of ‘array1';
local var2 : word ‘i' of ‘array2';

ttest `var1' = `var2';

local i = `i' + 1;

};

#delimit cr


but when i run it I get an "invalid syntax" error...I cannot understand why.


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