IBM Support

Unable to execute IF command, produces Error# 4285

Troubleshooting


Problem

When executing an IF command using Statistics Syntax, execution stops with the following error message: Error# 4285 in column . Text: Incorrect variable name: either the name is more than 64 characters, or it is not defined by a previous command. Execution of this command stops.

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.

[{"Product":{"code":"SSLVMB","label":"IBM SPSS Statistics"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Statistics Desktop","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Not Applicable","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

More support for:
IBM SPSS Statistics

Software version:
Not Applicable

Document number:
267407

Modified date:
16 April 2020

UID

swg21967706

Manage My Notification Subscriptions