SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Issue duplicate values in frequency table after computing new variable

    Posted Wed November 03, 2021 08:43 AM
    Dear all,

    I have computed a new variable (say 'delta') by substracting var1 from var2. Both var1 and var2 range from 1.0 to 6.0 and contain 1 decimal place,

    After having computed the delta variable I created a frequency table. It now seems that SPSS does not recognize some values that are the same as the same. Identical numbers are presented multiple times in the frequency table. See example in the screenshot below.

    I have tried the following:
    - Recreating delta from var1 and var2 
    - Checking the decimals. As stated it contains only 1, so there are no differences in the number after the 0. 
    - Recoding 'delta' into a new variable (-3.80=-3.80) (-3.20=-3.20) and so on. Then only some of the values are recoded into the new variable, but I don't see any pattern
    - Set the variable as nominal, ordinal, and scale

    As this should be just a very simple transformation, I have no clue what else could cause this issue. Does any of you have a suggestion?

    Thank you in advance!



    ------------------------------
    Annelot
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Issue duplicate values in frequency table after computing new variable

    Posted Wed November 03, 2021 09:44 AM
    This is likely an issue with floating point arithmetic precision due to the nature of floating point hardware and arithmetic.  FREQUENCIES will distinguish the values if there is any difference even in the last decimal place.
    Try setting the variable format to show a lot of decimal places or use scientific notation before running FREQUENCIES.

    The RECODE behavior supports this hypothesis.  You have some values that are not exactly equal to -3.80000000000 etc.

    If you can't figure this out and want to send me a sample of the data (jkpeck@gmail.com), I will take a look.


    --





  • 3.  RE: Issue duplicate values in frequency table after computing new variable

    Posted Wed November 03, 2021 09:47 AM
    Hi. Sounds like a formatting issue. The number held internally is not absolutely identical to the one displayed. It could be that you have 1.00 and 1.000001, but formatted to F8.2 (default) they both appear "1.00". Like this:


    and I get the kind of FREQ table you're seeing. But if I use the FORMATS command on that variable:

    FORMATS VAR00001 (F16.8).​

    the FREQ table looks like this:


    You can truncate or round the values to eliminate that kind of thing.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 4.  RE: Issue duplicate values in frequency table after computing new variable

    Posted Wed November 03, 2021 10:05 AM
    Edited by System Admin Fri January 20, 2023 04:26 PM
    Thank you both for your reactions!

    It was indeed a problem with the values not being exactly equal. This only showed after using the scientific notation and not when looking at the max of 16 decimal places as I did before. The round function solved the problem!

    Thanks again for your quick help!

    ------------------------------
    Annelot
    ------------------------------