Debugging Syntax
Home Up SPSS Tutorials Learning Syntax Debugging Syntax Standard Data Files

Enter keywords


Exact match


Advanced Search
Feedback
Site Map

 

Other languages
Deutsch
Español
Français
Italiano
Português

 

Do you love this site?

 

Debugging SPSS Syntax

It has been said that Salesmanship starts after the prospect has said "no!".

Similarly, programming could be said to start once there is a bug!

  1. Common errors and possible solutions
    This line of code does not work!
    My syntax works on a stand alone basis but fails when called via INCLUDE
    My DO IF ... ELSE ...END IF does not give the correct results!
    My vectors keep "disappearing"
    My SELECT IF does not select the correct cases!
    File is already in used
    Waiting for more inline data

 

Common errors and possible solutions

This line of code does not work!

Add a command terminator (a period) at the end of the preceding line.
If the status bar indicates "Transformations Pending " click on Run Pending Transformations.
Review the message in the log of the Output window.

I have also experienced situations where SPSS gets confused and does not recognize changes in a syntax file; it is as if SPSS continued to use the original syntax. Closing and restarting the software corrects those problems.

 

My syntax works on a stand alone basis but fails when called via INCLUDE

The syntax rules of the 2 run modes are slightly different. The main difference is that :
Commands in an included file must begin in column 1
continuation lines must be indented at least one column
.

Thus the following works in immediate (direct) mode:

DO IF (var1 > 0).
     COMPUTE var2=var1*2.
END IF.

but it does not work in the Included mode because COMPUTE does not start in column one. An alternative is to use a + or a - in the first column. The following would work

DO IF (var1 > 0).
+ COMPUTE var2=var1*2.
END IF.

 

My DO IF ... ELSE ...END IF does not give the correct results!

see Missing Values and DO IF.sps

 

My vectors keep "disappearing"

When you first create a vector say using VECTOR a(20F8.0) /b=var1 TO var20.

You can refer to each element using a LOOP for instance:

LOOP cnt=1 TO 20.
COMPUTE a(cnt)=a(cnt)*2.
COMPUTE b(cnt)=b(cnt)+15.
END LOOP.

As soon as you run a procedure or an EXECUTE, the vectors are no longer available. If you need them again, you must redefine them but this time the command is different for the vector "a" because the variables a1 TO a20 already exist.

You must use VECTOR a=a1 TO a20 /b=var1 TO var2.

 

My SELECT IF does not select the correct cases!

If the calculation of the value tested is ok, then insert an "EXECUTE." in the line above the SELECT IF. See also When to use EXECUTE.

 

File is already in used

 

When I try, using syntax,  to save a .sav file that already exists, I get a warning that the file already exists and that SPSS has renamed the file by placing a number on the end of the file name, e.g.

SAVE OUTFILE= 'Total.sav'
results in
total_1.sav being saved.

I really do want to save over the old files. Is there anyway to work around this "feature".

Comments: This problem exits in versions 10.xx and has been heard in version 11.

*** Possible solution no 1.

CACHE.
EXECUTE.
SAVE OUTFILE= 'Total.sav'

*** Possible solution no 2.

SAVE OUTFILE='c:\temp.sav'.
EXECUTE.
SAVE OUTFILE= 'Total.sav'.
EXECUTE.
ERASE FILE='c:\temp.sav'.

See also AnswerNet AnswerNet id=100007792

 

 

Waiting for more inline data

One way this error occurs is when you have a BEGIN DATA - END DATA block in your syntax and the END DATA does not start in the first column of the line.

To get rid of the message in the Processor Area of the status bar, place the cursor over the END DATA command and run that line.,

 

Top of page

AddFreeStats.com Free Web Stats in real-time !

 

 

 

This page was last updated on March 20, 2003.  Raynald's SPSS Tools

© Raynald Levesque 2001-04