Dear all,

Can someone help me loop across different rows performing multiple immediate statistical tests, i.e. "csi a b c d, exact" tests across rows and save the respective p value in a different column?
I was able to do it for just one row, since it is iterating on the same row and delivering the first row outcome several times, as much as the number of iterations needed.

Here is the code i am using:
[CODE][ gen id=_n
gen p_val=.

forvalues i = 1/`=_N' {
csi `=a' `=b' `=c' `=d', exact
replace in `i' p_val=r(p)
}/CODE]

Here is de data:
a b c d
1 28 11 20
5 24 6 25
3 26 4 27
5 24 11 20
2 27 4 27
1 28 13 18
1 28 12 19
4 25 7 24
2 27 13 18
0 29 2 29
2 27 2 29
2 27 5 26
3 26 0 31
2 27 1 30
9 20 14 17
3 26 6 25
0 29 4 27
0 29 0 31
16 13 5 26
6 23 3 28


Thank you in advance.

Gonçalo Cotovio