3
votes

I am working in SPSS and have a large number of variables, call them v1 to v7000.

I want to perform a series of "complex operations" on each variable to create a new set of variables: t1 to t7000.

For the sake of illustration, let's just say the "complex operation" is to have t1 be the square of v1, t2 be the square of v2, etc.

My thought is to write some code like this.

do repeat t=t1 to t7000
compute t = v*v;
end repeat.

But, I don't think this will work.

What is the right way to do this? Thanks so much in advance.

1
7000 variables??? Perhaps an array is in order? - Mitch Wheat
Thank you for your swift reply. I will look into how to use arrays in SPSS and report back if I find success. :-) - al wong
Oh, and incidentally, regarding your question, it is 7000 variables (7368 to be exact). Though, perhaps even more staggering is that it is 23000 cases. :-) It is a massive database research project. Thanks again. - al wong

1 Answers

5
votes

Multiple stand-in variables can be specified on a DO REPEAT command.

do repeat t = t1 to t7000
 /v = v1 to v7000.
compute t = v**2.
end repeat.