Spss create new variable from multiple variables

In SPSS, you can create a new variable from multiple variables using the COMPUTE command or the RECODE command. Here are some examples:

Using the COMPUTE command:

Let's say you have three variables: x1, x2, and x3, and you want to create a new variable new_var that is the sum of x1 and x2.

COMPUTE new_var = x1 + x2.
EXECUTE.

This will create a new variable new_var that is the sum of x1 and x2.

Using the RECODE command:

Let's say you have two variables: x1 and x2, and you want to create a new variable new_var that is the result of a conditional statement. For example, if x1 is greater than 5, then new_var is 1, otherwise it's 0.

RECODE x1 (gt 5 = 1) (ELSE = 0) INTO new_var.
EXECUTE.

This will create a new variable new_var that is 1 if x1 is greater than 5, and 0 otherwise.

Using the VARSTOCASE command:

Let's say you have two variables: x1 and x2, and you want to create a new variable new_var that is a concatenation of x1 and x2.

VARSTOCASE x1 x2 INTO new_var.
EXECUTE.

This will create a new variable new_var that is a concatenation of x1 and x2.

Using the AGGREGATE command:

Let's say you have multiple variables: x1, x2,..., xn, and you want to create a new variable new_var that is the average of all these variables.

AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /VARIABLES=new_var AVG(x1 x2... xn).
EXECUTE.

This will create a new variable new_var that is the average of all the variables x1, x2,..., xn.

Note: In all cases, you need to execute the command using the EXECUTE command.