I'm using SPSS to create a variable that is supposed to show the numerical distance between a case and a given value. My mathmatical/programming skills are too limited to figure this out though and I could not find any tutorial pertaining to this online. Does anyone here have an idea on how to compute this?
To be clear, what I need is the distance from a case to a given number where the given number is always the same for instance at a given value of 10:
Case says: 4
Distance is 6
Case says: 15
Distance is 5
I have no clue how to fix this mathmatically or as a function in SPSS. Any help would be greatly appreciated.
dist=|case-10|
?
>>135687
Thats what I tried first but I need distances as positive numbers, that method also gives negative answers.
>>135690
>absolute value
>negative numbers
>>135691
I literally do not know what those things mean. I'm a political science student so I can't into math at all... Am I missing something here?
>>135694
https://en.wikipedia.org/wiki/Absolute_value
I don't believe you have never heard about this.
Update: SPSS can't handle the | | part. I found out that you can compute a variable with negative and positive values into an absolute value variable using the command:
COMPUTE new_var=ABS(old_var)
So I guess to get it to work in SPSS takes 2 steps.
>>135703
If only there were some way to combine two expressions.
>>135709
I sense a bit of sarcasm but thats okay, I know I'm completely retarded when it comes to this stuff but it works now so I'm happy enough :)