Troubleshooting
Problem
When executing an IF command using Statistics Syntax, execution stops with the following error message:
Error# 4285 in column
Symptom
Syntax being executed appears as:
IF (MySourceVariable=MyValue1) MyTargetVariable=1.
IF (MySourceVariable=MyValue2) MyTargetVariable=2.
EXECUTE.
Cause
Error is displayed because the end-user failed to encapsulate the string text within apostrophes ( ' ) or double-quoation ( " ) marks. Because the values that the IF command is looking up is not surrounded by quotes or apostrophes, SPSS Statistics thinks that it is supposed to be looking up a variable name.
Environment
This issue is not depended on a specific platform
Diagnosing The Problem
Review IF command and compare it to the example found in the Command Syntax Reference Guide > IF:
IF with String Values
IF (SEX EQ 'F') EEO=QUOTA+GAIN.
* The logical expression tests the string variable SEX for the value F.
* When the expression is true (when SEX equals F), the value of the numeric variable EEO is assigned the value of QUOTA plus GAIN. Both QUOTA and GAIN must be previously defined numeric variables.
* When the expression is false or missing (for example, if SEX equals F), the value of EEO remains unchanged. If EEO has not been previously defined, it contains the system-missing value.
Resolving The Problem
Surround the value of a string variable in apostrophe's or double-quote marks to successfully execute this command. The correct syntax would be:
IF (MySourceVariable='MyValue1') MyTargetVariable=1.
IF (MySourceVariable='MyValue2') MyTargetVariable=2.
EXECUTE.
Related Information
Was this topic helpful?
Document Information
Modified date:
16 April 2020
UID
swg21967706