# Question about compute ABS formula SPSS Classic List Threaded 8 messages Open this post in threaded view
|

## Question about compute ABS formula SPSS

 Hello everyone, I need help with the analysis of the data for my thesis. I have imported all the data from an Excel file, but the data were classified as string variables. To run the syntax compute variable, I had to change the variables to numeric variables. So I did that with Automatic Recode and it worked, but when I run the syntax now, it calculates all the labels instead of the actual values. This is the formula COMPUTE trajlength = ABS(X_2 - X_1) + ABS(X_3 - X_2) + ABS(X_4 - X_3) + ABS(X_5 - X_4) + ABS(X_6 - X_5) + ABS(X_7 - X_6) + ABS(X_8 - X_7) + ABS(X_9 - X_8) + ABS(X_10 - X_9) + ABS(X_11 - X_10) + ABS(X_12 - X_11) + ABS(X_13 - X_12) + ABS(X_14 - X_13) + ABS(X_15 - X_14) + ABS(X_16 - X_15) + ABS(X_17 - X_16) + ABS(X_18 - X_17) + ABS(X_19 - X_18) + ABS(X_20 - X_19) + ABS(X_21 - X_20) + ABS(X_22 - X_21) + ABS(X_23 - X_22) + ABS(X_24 - X_23) + ABS(X_25 - X_24) + ABS(X_26 - X_25) + ABS(X_27 - X_26) + ABS(X_28 - X_27) + ABS(X_29 - X_28) + ABS(X_30 - X_29) + ABS(X_31 - X_30) + ABS(X_32 - X_31) + ABS(X_33 - X_32) + ABS(X_34 - X_33) + ABS(X_35 - X_34) + ABS(X_36 - X_35) + ABS(X_37 - X_36) + ABS(X_38 - X_37) + ABS(X_39 - X_38) + ABS(X_40 - X_39) + ABS(X_41 - X_40) + ABS(X_42 - X_41) + ABS(X_43 - X_42) + ABS(X_44 - X_43) + ABS(X_45 - X_44) + ABS(X_46 - X_45) + ABS(X_47 - X_46) + ABS(X_48 - X_47) + ABS(X_49 - X_48) + ABS(X_50 - X_49) + ABS(X_51 - X_50) + ABS(X_52 - X_51) + ABS(X_53 - X_52) + ABS(X_54 - X_53) + ABS(X_55 - X_54) + ABS(X_56 - X_55) + ABS(X_57 - X_56) + ABS(X_58 - X_57) + ABS(X_59 - X_58) + ABS(X_60 - X_59) + ABS(X_61 - X_60) + ABS(X_62 - X_61) + ABS(X_63 - X_62) + ABS(X_64 - X_63) + ABS(X_65 - X_64) + ABS(X_66 - X_65) + ABS(X_67 - X_66) + ABS(X_68 - X_67) + ABS(X_69 - X_68) + ABS(X_70 - X_69) + ABS(X_71 - X_70) + ABS(X_72 - X_71) + ABS(X_73 - X_72) + ABS(X_74 - X_73) + ABS(X_75 - X_74) + ABS(X_76 - X_75) + ABS(X_77 - X_76) + ABS(X_78 - X_77) + ABS(X_79 - X_78) + ABS(X_80 - X_79) + ABS(X_81 - X_80) + ABS(X_82 - X_81) + ABS(X_83 - X_82) + ABS(X_84 - X_83) + ABS(X_85 - X_84) + ABS(X_86 - X_85) + ABS(X_87 - X_86) + ABS(X_88 - X_87) + ABS(X_89 - X_88) + ABS(X_90 - X_89) + ABS(X_91 - X_90) + ABS(X_92 - X_91) + ABS(X_93 - X_92) + ABS(X_94 - X_93) + ABS(X_95 - X_94) + ABS(X_96 - X_95) + ABS(X_97 - X_96) + ABS(X_98 - X_97) + ABS(X_99 - X_98) + ABS(X_100 - X_99) + ABS(X_101 - X_100). So for example, the actual data is -0.002 and -0.004 but because of the labels these are numbered 12 and 14. That means that the outcomes under the new variable are not the actual values and these are actually way higher than should be. Is there any way that I can remove these labels or do something else so that the formula calculates the right values? -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Open this post in threaded view
|

## Re: Question about compute ABS formula SPSS

 Hi,try the VALUELABEL function like this:``````STRING X_1s (A20). COMPUTE X_1s = VALUELABEL(X_1).``````Good luck,Mario GieselMunich, Germany Am Mittwoch, 30. Dezember 2020, 15:05:07 MEZ hat LO2345 <[hidden email]> Folgendes geschrieben: Hello everyone,I need help with the analysis of the data for my thesis. I have imported allthe data from an Excel file, but the data were classified as stringvariables. To run the syntax compute variable, I had to change the variablesto numeric variables. So I did that with Automatic Recode and it worked, butwhen I run the syntax now, it calculates all the labels instead of theactual values.This is the formulaCOMPUTE trajlength = ABS(X_2 - X_1) + ABS(X_3 - X_2) + ABS(X_4 - X_3) +ABS(X_5 - X_4) + ABS(X_6 - X_5) +ABS(X_7 - X_6) + ABS(X_8 - X_7) + ABS(X_9 - X_8) + ABS(X_10 - X_9) +ABS(X_11 - X_10) +ABS(X_12 - X_11) + ABS(X_13 - X_12) + ABS(X_14 - X_13) + ABS(X_15 - X_14) +ABS(X_16 - X_15) +ABS(X_17 - X_16) + ABS(X_18 - X_17) + ABS(X_19 - X_18) + ABS(X_20 - X_19) +ABS(X_21 - X_20) +ABS(X_22 - X_21) + ABS(X_23 - X_22) + ABS(X_24 - X_23) + ABS(X_25 - X_24) +ABS(X_26 - X_25) +ABS(X_27 - X_26) + ABS(X_28 - X_27) + ABS(X_29 - X_28) + ABS(X_30 - X_29) +ABS(X_31 - X_30) +ABS(X_32 - X_31) + ABS(X_33 - X_32) + ABS(X_34 - X_33) + ABS(X_35 - X_34) +ABS(X_36 - X_35) +ABS(X_37 - X_36) + ABS(X_38 - X_37) + ABS(X_39 - X_38) + ABS(X_40 - X_39) +ABS(X_41 - X_40) +ABS(X_42 - X_41) + ABS(X_43 - X_42) + ABS(X_44 - X_43) + ABS(X_45 - X_44) +ABS(X_46 - X_45) +ABS(X_47 - X_46) + ABS(X_48 - X_47) + ABS(X_49 - X_48) + ABS(X_50 - X_49) +ABS(X_51 - X_50) +ABS(X_52 - X_51) + ABS(X_53 - X_52) + ABS(X_54 - X_53) + ABS(X_55 - X_54) +ABS(X_56 - X_55) +ABS(X_57 - X_56) + ABS(X_58 - X_57) + ABS(X_59 - X_58) + ABS(X_60 - X_59) +ABS(X_61 - X_60) +ABS(X_62 - X_61) + ABS(X_63 - X_62) + ABS(X_64 - X_63) + ABS(X_65 - X_64) +ABS(X_66 - X_65) +ABS(X_67 - X_66) + ABS(X_68 - X_67) + ABS(X_69 - X_68) + ABS(X_70 - X_69) +ABS(X_71 - X_70) +ABS(X_72 - X_71) + ABS(X_73 - X_72) + ABS(X_74 - X_73) + ABS(X_75 - X_74) +ABS(X_76 - X_75) +ABS(X_77 - X_76) + ABS(X_78 - X_77) + ABS(X_79 - X_78) + ABS(X_80 - X_79) +ABS(X_81 - X_80) +ABS(X_82 - X_81) + ABS(X_83 - X_82) + ABS(X_84 - X_83) + ABS(X_85 - X_84) +ABS(X_86 - X_85) +ABS(X_87 - X_86) + ABS(X_88 - X_87) + ABS(X_89 - X_88) + ABS(X_90 - X_89) +ABS(X_91 - X_90) +ABS(X_92 - X_91) + ABS(X_93 - X_92) + ABS(X_94 - X_93) + ABS(X_95 - X_94) +ABS(X_96 - X_95) +ABS(X_97 - X_96) + ABS(X_98 - X_97) + ABS(X_99 - X_98) + ABS(X_100 - X_99) +ABS(X_101 - X_100).So for example, the actual data is -0.002 and -0.004 but because of thelabels these are numbered 12 and 14. That means that the outcomes under thenew variable are not the actual values and these are actually way higherthan should be.Is there any way that I can remove these labels or do something else so thatthe formula calculates the right values?--=====================To manage your subscription to SPSSX-L, send a message to[hidden email] (not to SPSSX-L), with no body text except thecommand. To leave the list, send the commandSIGNOFF SPSSX-LFor a list of commands to manage subscriptions, send the commandINFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Open this post in threaded view
|

## Re: Question about compute ABS formula SPSS

 In reply to this post by LO2345 I answered this earlier on the IBM Predictive Analytics site.On Wed, Dec 30, 2020 at 7:05 AM LO2345 <[hidden email]> wrote:Hello everyone, I need help with the analysis of the data for my thesis. I have imported all the data from an Excel file, but the data were classified as string variables. To run the syntax compute variable, I had to change the variables to numeric variables. So I did that with Automatic Recode and it worked, but when I run the syntax now, it calculates all the labels instead of the actual values. This is the formula COMPUTE trajlength = ABS(X_2 - X_1) + ABS(X_3 - X_2) + ABS(X_4 - X_3) + ABS(X_5 - X_4) + ABS(X_6 - X_5) + ABS(X_7 - X_6) + ABS(X_8 - X_7) + ABS(X_9 - X_8) + ABS(X_10 - X_9) + ABS(X_11 - X_10) + ABS(X_12 - X_11) + ABS(X_13 - X_12) + ABS(X_14 - X_13) + ABS(X_15 - X_14) + ABS(X_16 - X_15) + ABS(X_17 - X_16) + ABS(X_18 - X_17) + ABS(X_19 - X_18) + ABS(X_20 - X_19) + ABS(X_21 - X_20) + ABS(X_22 - X_21) + ABS(X_23 - X_22) + ABS(X_24 - X_23) + ABS(X_25 - X_24) + ABS(X_26 - X_25) + ABS(X_27 - X_26) + ABS(X_28 - X_27) + ABS(X_29 - X_28) + ABS(X_30 - X_29) + ABS(X_31 - X_30) + ABS(X_32 - X_31) + ABS(X_33 - X_32) + ABS(X_34 - X_33) + ABS(X_35 - X_34) + ABS(X_36 - X_35) + ABS(X_37 - X_36) + ABS(X_38 - X_37) + ABS(X_39 - X_38) + ABS(X_40 - X_39) + ABS(X_41 - X_40) + ABS(X_42 - X_41) + ABS(X_43 - X_42) + ABS(X_44 - X_43) + ABS(X_45 - X_44) + ABS(X_46 - X_45) + ABS(X_47 - X_46) + ABS(X_48 - X_47) + ABS(X_49 - X_48) + ABS(X_50 - X_49) + ABS(X_51 - X_50) + ABS(X_52 - X_51) + ABS(X_53 - X_52) + ABS(X_54 - X_53) + ABS(X_55 - X_54) + ABS(X_56 - X_55) + ABS(X_57 - X_56) + ABS(X_58 - X_57) + ABS(X_59 - X_58) + ABS(X_60 - X_59) + ABS(X_61 - X_60) + ABS(X_62 - X_61) + ABS(X_63 - X_62) + ABS(X_64 - X_63) + ABS(X_65 - X_64) + ABS(X_66 - X_65) + ABS(X_67 - X_66) + ABS(X_68 - X_67) + ABS(X_69 - X_68) + ABS(X_70 - X_69) + ABS(X_71 - X_70) + ABS(X_72 - X_71) + ABS(X_73 - X_72) + ABS(X_74 - X_73) + ABS(X_75 - X_74) + ABS(X_76 - X_75) + ABS(X_77 - X_76) + ABS(X_78 - X_77) + ABS(X_79 - X_78) + ABS(X_80 - X_79) + ABS(X_81 - X_80) + ABS(X_82 - X_81) + ABS(X_83 - X_82) + ABS(X_84 - X_83) + ABS(X_85 - X_84) + ABS(X_86 - X_85) + ABS(X_87 - X_86) + ABS(X_88 - X_87) + ABS(X_89 - X_88) + ABS(X_90 - X_89) + ABS(X_91 - X_90) + ABS(X_92 - X_91) + ABS(X_93 - X_92) + ABS(X_94 - X_93) + ABS(X_95 - X_94) + ABS(X_96 - X_95) + ABS(X_97 - X_96) + ABS(X_98 - X_97) + ABS(X_99 - X_98) + ABS(X_100 - X_99) + ABS(X_101 - X_100). So for example, the actual data is -0.002 and -0.004 but because of the labels these are numbered 12 and 14. That means that the outcomes under the new variable are not the actual values and these are actually way higher than should be. Is there any way that I can remove these labels or do something else so that the formula calculates the right values? -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD -- Jon K Peck[hidden email] ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Open this post in threaded view
|

## Re: Question about compute ABS formula SPSS

 In reply to this post by LO2345 Make a U turn. AUTORECODE while very useful in some cases is a lethal dead end for you. Before you crash and burn look into the NUMBER function to convert your string values to proper numerical values. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Open this post in threaded view
|

## Re: Question about compute ABS formula SPSS

 The answer I posted was to just use ALTER TYPE on all those variables - one command.On Wed, Dec 30, 2020 at 7:26 AM David Marso <[hidden email]> wrote:Make a U turn. AUTORECODE while very useful in some cases is a lethal dead end for you. Before you crash and burn look into the NUMBER function to convert your string values to proper numerical values. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD -- Jon K Peck[hidden email] ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Open this post in threaded view
|