Re: do repeat

Posted by Andy W on
URL: http://spssx-discussion.165.s1.nabble.com/do-repeat-tp5719707p5719709.html

It works for me as long as you define the "bOdd1_WIN.(#i)" vector.

VECTOR bOdd1_WIN_p.(48).
VECTOR bOdd1_WIN. = bOdd1_WIN.1 to bOdd1_WIN.48.
DO REPEAT #i = 1 to 48.
COMPUTE bOdd1_WIN_p.(#i) = 1/bOdd1_WIN.(#i).
END REPEAT.
EXECUTE.

You have quite the way with variable names.

*******************************************************.
*complete example.
data list free / id.
begin data
1
2
3
4
5
end data.

vector bOdd1_WIN.(48).
loop #i = 1 to 48.
compute bOdd1_WIN.(#i) = RV.UNIFORM(1,5).
end loop.
exe.

*Old Code.
VECTOR bOdd1_WIN_p.(48).
DO REPEAT #i = 1 to 48.
COMPUTE bOdd1_WIN_p.(#i) = 1/bOdd1_WIN.(#i).
END REPEAT.
EXECUTE.
*This does not work since "bOdd1_WIN.(#i)" vector is not defined.

*Old code works if you define that vector.
match files file = *
/drop bOdd1_WIN_p.1 to bOdd1_WIN_p.48.
exe.

*Updated Code.
VECTOR bOdd1_WIN_p.(48).
VECTOR bOdd1_WIN. = bOdd1_WIN.1 to bOdd1_WIN.48.
DO REPEAT #i = 1 to 48.
COMPUTE bOdd1_WIN_p.(#i) = 1/bOdd1_WIN.(#i).
END REPEAT.
EXECUTE.
********************************************************.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/