### recoding a variable with conditions on other variables in other entries...

Posted:

**Wed Mar 01, 2017 8:32 pm**Hi,

I am stuck with a variable recoding in a 200 000 entries database, so please help!

Here's an example of what i'd like to do:

Consider these 3 variables X, Y and Z

X Y Z

1 1 1

1 1 2

1 2 2

2 1 5

2 1 1

2 1 2

2 2 2

2 3 5

IF Y=1 THEN look the other entries having the same X value

Among these IF you find one entry with Y different than 1, keep in memory its Y value THEN DO THE FOLLOWING

for all the entries having the same X value and the same Z value RECODE Y into the Y value recorded

look for the other entries with Y different than 1 (The possible values of Y are {1, 2 or 3})

So that on the given example the result would be the following:

X Y Z

1 1 1

1 2 2

1 2 2

2 3 5

2 1 1

2 2 2

2 2 2

2 3 5

Is there a way to do this in SPSS??

I would really appreciate the help... otherwise it is going to be days in cleaning the database up!!

Many thanks in advance!

Sara

I am stuck with a variable recoding in a 200 000 entries database, so please help!

Here's an example of what i'd like to do:

Consider these 3 variables X, Y and Z

X Y Z

1 1 1

1 1 2

1 2 2

2 1 5

2 1 1

2 1 2

2 2 2

2 3 5

IF Y=1 THEN look the other entries having the same X value

Among these IF you find one entry with Y different than 1, keep in memory its Y value THEN DO THE FOLLOWING

for all the entries having the same X value and the same Z value RECODE Y into the Y value recorded

look for the other entries with Y different than 1 (The possible values of Y are {1, 2 or 3})

So that on the given example the result would be the following:

X Y Z

1 1 1

1 2 2

1 2 2

2 3 5

2 1 1

2 2 2

2 2 2

2 3 5

Is there a way to do this in SPSS??

I would really appreciate the help... otherwise it is going to be days in cleaning the database up!!

Many thanks in advance!

Sara