al wong
al wong

Reputation: 31

SPSS: Looping over Several Variables

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.

Upvotes: 3

Views: 1164

Answers (1)

djhurio
djhurio

Reputation: 5536

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.

Upvotes: 5

Related Questions