About INCLUDing files
If a Syntax file is called through an INCLUDE
command, it is recommended to have a comment ( a line which starts with an * and ends with a period) in the first line of the syntax. This is to circumvent reported occurrences of the interpreter silently "swallowing" the first line code.
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, or interactive) 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.
Either of the following variation does work when the code is invoked by INCLUDE
:
DO IF (var1 > 0). - COMPUTE var2=var1*2. END IF.
or
DO IF (var1 > 0). COMPUTE var2=var1*2. END IF.
See Execute selective portions of syntax.SPS for a typical use of the INCLUDE
command. It is important to know that the processing of a file that is called by the INCLUDE
command stops as soon as an error occurs. Some warnings also stop the execution of the file.
The following 2 situations are common with INCLUDE
files.
- Sometimes the user would like the syntax to simply continue to execute the subsequent command of the included file (this is what happens when the syntax file is run from the syntax window). See Include stops because select if results in no data.SPS for a possible solution.
- Sometimes the include file is very long and because a certain condition occurs, the user would like to stop the processing of the syntax file. See Choice of include file depends on data.SPS for a possible solution to this problem.
...