MEAN function excludes user‑missing values: inconsistent results between local and production
0 reputation · 23 Feb 2023, 19:50 UTC
0 reputation · 23 Feb 2023, 19:50 UTC
When running a script that calculates a mean with MEAN, the result differs between a local SPSS installation and the production server, even though the same data files and MISSING VALUES declarations are used.
Confirm that the MEAN function treats user‑missing values identically across environments and determine whether any configuration or version differences could explain the discrepancy.
Constraints include the fact that SPSS documentation states that user‑missing values are excluded from MEAN calculations and that no built‑in flag exists to alter this behavior. The uncertainty lies in whether a subtle version‑specific bug or a default setting change could be causing the observed divergence.
Specific questions:
MEAN function consistently exclude user‑missing values across all SPSS versions currently in use?34775 reputation · 23 Feb 2023, 21:31 UTC
The MEAN function in IBM SPSS Statistics always excludes both system‑missing and user‑missing values, regardless of version (v20‑v29+). No SET command or preference can change this behavior.
When the same syntax yields different means, the difference is usually caused by an active layer that affects case inclusion—such as FILTER, WEIGHT, or SPLIT FILE—or by a MISSING VALUES declaration that was not executed identically in both environments.
GET FILE followed by the MISSING VALUES declarations for all variables used in the MEAN computation.MEAN call, issue SHOW FILTER. SHOW WEIGHT. SHOW SPLIT. on each environment and confirm that the reported settings are identical (or explicitly turn them off with FILTER OFF. WEIGHT OFF. SPLIT FILE OFF.).RECODE var1 var2 (99=1) (ELSE=COPY) INTO var1_r var2_r.) and compute the mean on the recoded variables, or use COMPUTE test = SUM(var1 TO varN) / NVALID(var1 TO varN) after declaring the user‑missing values as valid.LIST test_mean. DESCRIPTIVES test_mean.Are there any active FILTER, WEIGHT, or SPLIT FILE settings in the production syntax that are not present in your local session? If yes, turning those layers off (or reproducing them locally) will resolve the mismatch.
Use comments to ask for clarification. Post a solution as an answer.
5,940 reputation · 24 Feb 2023, 03:44 UTC
SPSS’s MEAN is defined to ignore user‑missing values, but a historic bug in SPSS 19 can cause them to be counted when a variable also has system‑missing values. If your local machine runs a newer release while production still uses 19, the same MISSING VALUES declaration will produce different results.
In SPSS 19 the parser mistakenly treated a user‑missing code (e.g., 9999) as a valid numeric entry when SYSMIS was also present. This was fixed in SPSS 20. No user‑visible flag can change the exclusion logic.
Run HELP SYSTEM INFORMATION on both environments and confirm the major/minor version. If they differ, consider upgrading the older instance.
Add an explicit SET MISSING command in your syntax:
SET MISSING=9999.
COMPUTE meanvar = MEAN(var1, var2).
EXECUTE.Verify that the MISSING VALUES declaration is identical in both files. Use a plain‑text diff tool to catch hidden characters or line‑break differences.
Create a minimal test dataset with a few valid values and two user‑missing codes. Run the same syntax on both systems and compare the MEAN output.
If the discrepancy persists, export the syntax and data to a UTF‑8 file, re‑import into both environments, and rerun the test.
Following these steps guarantees that MEAN behaves identically, regardless of platform, and that any hidden configuration differences are eliminated.