1
votes

I would create a variable in SPSS and add it in the existing dataset. Particularly this variable should be: x-y if x>y and 0 if x<=y (x and y are variables in the dataset). How can I do?

I'm interested to learn this both writing the syntax of the script as using the guided tool "compute variable".

thanks in advance

2

2 Answers

1
votes

There are many ways to do this. The simplest is compute z = max(x-y, 0).

0
votes

Here's another one liner:

compute z = (x-y)*(x>y).