Reputation: 25
I was very happy to be introduced to SPSS macros by this question. I am using the exact code that was suggested there. See below for an example. I ran this code on 26 December 2015, and it executed flawlessly. I then made changes to other parts of the syntax file. I did not change one character in the code below. I tried to run everything again today, and I am experiencing a very strange problem. SPSS says something like the following for each subprogram:
Text: macro Command: FREQUENCIES
An undefined variable name, or a scratch or system variable was specified in a variable list which accepts only standard variables. Check spelling and verify the existence of this variable. Execution of this command stops.
It then says the following:
Error # 1. Command name: text
The first word in the line is not recognized as an SPSS Statistics command. Execution of this command stops.
Interestingly, then, all the output appears in the exact place that it should. Therefore, I should not complain, but it is very disconcerting. I do not understand why it would not give any errors the first time and then give me errors on subsequent attempts. I am using SPSS 19 on Mac OS 10.8.5.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* Wakefulness condition.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
USE ALL .
COMPUTE filter_$=(include_analysis = 1 & group_rand = 0) .
FILTER BY filter_$ .
EXECUTE .
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* !comp_dich
* This macro/text replacement device/string parser performs some basic comparisons using
* a dichotomous variable.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DEFINE !comp_dich (!POS !CHAREND('/'))
!DO !i !IN (!1)
FREQUENCIES
VARIABLES=!i
/ORDER=ANALYSIS .
CROSSTABS
/TABLES=!i BY gender
/FORMAT=AVALUE TABLES
/STATISTICS=MCNEMAR
/CELLS=COUNT EXPECTED ROW COLUMN TOTAL
/COUNT ROUND CELL .
CROSSTABS
/TABLES=!i BY vis_train
/FORMAT=AVALUE TABLES
/STATISTICS=MCNEMAR
/CELLS=COUNT EXPECTED ROW COLUMN TOTAL
/COUNT ROUND CELL .
T-TEST GROUPS=!i(0 1)
/MISSING=ANALYSIS
/VARIABLES=/*
age/*
dose/*
t_l_mean_am/*
t_l_mean_pm/*
threshold_am/*
threshold_pm/*
diff_thresh/*
TDT_defaults_am/*
TDT_defaults_pm/*
TTC_am/*
TTC_pm/*
full_wake/*
full_N1/*
full_N2/*
full_N3/*
full_REM/*
full_tst/*
full_trt/*
scan_wake/*
scan_N1/*
scan_N2/*
scan_N3/*
scan_REM/*
scan_tst/*
scan_trt/*
peak_wake/*
peak_N1/*
peak_N2/*
peak_N3/*
peak_REM/*
peak_tst/*
peak_trt/*
weigh_sws/*
/CRITERIA=CI(.95) .
!DOEND
!ENDDEFINE .
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* I call the !comp_dich macro/text replacement device/string parser.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!comp_dich
sx_rcps_cuneate_dtu_dich /.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* Sleep condition.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
USE ALL .
COMPUTE filter_$=(include_analysis = 1 & group_rand = 1) .
FILTER BY filter_$ .
EXECUTE .
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* I call the !comp_dich macro/text replacement device/string parser.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
!comp_dich
sx_rcps_cuneate_dtu_dich /.
Upvotes: 2
Views: 2285
Reputation: 2929
Try deleting the line
* !comp_dich
From:
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* !comp_dich
* This macro/text replacement device/string parser performs some basic comparisons using
* a dichotomous variable.
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
As an asterisk alone unfortunately does not comment out a macro call, only /*
does.
Upvotes: 2
Reputation: 2929
Before you run the code:
!comp_dich
sx_rcps_cuneate_dtu_dich /.
Try prefixing it with SET MPRINT ON.
i.e:
set mprint on.
!comp_dich
sx_rcps_cuneate_dtu_dich /.
This should then help identify which statement extacly is causing a problem, you will see in your output a printback of the statement followed by the error message. The combination should give you enough to go on to isolate the problem...
It's likely, going by the error message you descirbe, a variable being specifed does not exist in the data or there is someother syntax error.
Upvotes: 2
Reputation: 5536
As Jignesh has correctly commented. This is not a problem for the latest SPSS versions. But I believe it is worth to try, because this was a problem for older SPSS versions.
As far as I remember there is a rule with SPSS macro syntax: do not end a line with a macro name. I am guessing this could be a reason for the error. Try to rewrite the FREQUENCIES comand in two lines. For example:
FREQUENCIES
VARIABLES=!i /ORDER=ANALYSIS .
This is my guess as I do not have data available to test it.
Upvotes: 0