# Create variable based on two existing ones

#### Jeric

##### New Member
Good morning!
I come back on SPSS for my master thesis and I get stuck on an basic issue...

I want to "merge" two variables in one as follow:
My two variables are:
- Birthplace of the mother: coded 1 for "born in the country" and 2 for "abroad" (variable called "motherbirth")
- Birthplace of the father: same code (variable called "fatherbirth")

I just want to create the variable "parentsbirth" which will resume if at least one of the two parents born abroad, (with the same code) so I guess the following reasoning:
If "motherbirth" OR/AND "fatherbirth" contain "2", then "parentsbirth" will be 2, if no one contain 2 then "parentsbirth" will be 1.

I tried everything, I looked for tutorials, but I didn't manage it...
Thank you so much for your help

Jeric

#### Karabiner

##### TS Contributor
IF ( (fatherbird + motherbird) < 3) parentsbirt = 1 .
IF ( (fatherbird + motherbird) >= 3) parentsbirt = 2 .
EXECUTE .

Supposedly, there will be missing values for fatherbird or motherbird in some cases.
For those cases, parentsbirth will be missing also.

With kind regards

Karabiner

#### Jeric

##### New Member
Dear Karabiner,
Thank you so much!

I am working on PIAAC (OECD database).
It also propose the following answers:
6: Valid skip
7: Don't know
8: Refused
9: Not stated or inferred

So, I tried to do:
IF ( (J_Q06a + J_Q07a) < 3) parentsbirthplace = 1 .
IF ( (J_Q06a + J_Q07a) >= 3 <= 4) parentsbirthplace = 2 . (Is the "<=4" necessary? Or the following IF will work in any case?)
IF ( (J_Q06a + J_Q07a) >= 6 ) parentsbirthplace = 6 . (I will consider the old 6/7/8/9 in a new global 6 called "missing")
EXECUTE .

Do you think it is correct?
With this formula, the problem is if the answer of one of the parents is not 1 or 2 (but 6/7/8/9), "parentsbirthplace" will be considered missing in anycase, isn't it?
Is there a way to consider this issue? (like, if we have only one parents' answer, we take this one).

In any case thank you a lot for your quick answer which helped me a lot!
Jeric