Reputation: 183
My syntax worked perfectly fine, but after closing SPSS and opening the dataset again I get the error 4285. I would appreciate if you help me to understand why it is happening.
My dataset looks like this:
University School
TU LE
SL LO
RT KS
I need to create a new variable "Education" with data from the variable "University"(0) and "School"(1).
Syntax that I have written:
DATASET NAME dataset1.
DATASET ACTIVATE dataet1.
IF University = "TU" Education = 0.
IF School = "LO" Education = 1.
IF University = "RT" Education = 0.
Upvotes: 1
Views: 3011
Reputation: 1044
First: there is a mistake in the name of the dataset in the code you pasted/wrote here. When you called the command DATASET ACTIVATE
you wrote dataet1
, instead of dataset1
. You are missing the letter "s". Check if this mistake is also in your code.
Second: your code works fine with your data, I tested here and got the right output.
Third: Probably you have multiple datasets open and you are naming and referring to the wrong one. I also tested for that and I got the same error code you had:
IF University = "TU" Education = 0.
>Error # 4285 in column 4. Text: University
>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.
IF School = "LO" Education = 1.
I would suggest that you save properly and close all open datasets. Then open just the dataset you want and run the code again.
Fourth: one way to avoid such mistakes is by naming properly the dataset at the moment you open it, preferably with a name that makes sense to you. For example, you can name this one as Educ_data
:
GET
FILE='C:\Data\Universities.sav'.
DATASET NAME Educ_data WINDOW=FRONT.
By doing so, you:
DATASET NAME
when you open or create a new dataset, and never again while manipulating data. This way you avoid assigning the wrong name to the last dataset you viewed. If you are not creating or opening a new dataset, you just use DATASET ACTIVATE
.Upvotes: 2