Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using VECTORS in a DO REPEAT loop ?

4 views
Skip to first unread message

Dimitri Mortelmans

unread,
Aug 26, 2002, 3:27:00 AM8/26/02
to
Hello,

I want to tackle the following problem:
I have 10 variables with 5 values (1 to 5). I want to recode these 10
variables in 10 new variables with only 3 values (1 to 3) whereby 1 and 2
are converted into 1 / 3 is converted into 2 and 4 and 5 are converted into
3. I do not want to repeat the RECODe-code ten times so I want to use loops.

I used the following program to do this:


* The existing variables.
VECTOR VAR= v1001 TO v1005 .
* The new variables .
VECTOR SCH = SCH1 TO SCH10.

LOOP #I = 1 to 10.
+ DO REPEAT A= 1 2 3 4 5 / B = 1 1 2 3 3.
+ RECODE VAR(#I) (A=B) INTO SCH(#I).
+ END REPEAT PRINT.
END LOOP.

EXECUTE.

The problem is that SPSS does not subsitute the variable names from the
vectors within the DO REPEAT loop. Anybody an idea how I can resolve this ?

Thanks,

Dimitri Mortelmans


Arthur J. Kendall

unread,
Aug 26, 2002, 8:34:33 AM8/26/02
to
Is this what you want to do?
(I made up xxx1 to xxx5 so there would be 10 variables.)
numeric sch01 to sch10 (f1).
recode var1001 to var1005 xxx1 to xxx5 (1,2=1)(3=2)(4,5=3) into sch01 to sch10.

Hope this helps.
Art
A...@DrKendall.org
University Park, MD USA

0 new messages