Determining Command Order
The table Table 1 shows where specific commands can be placed in the command file in terms of program states and what happens when the program encounters a command in each of the four program states. If a column contains a dash, the command is accepted in that program state and it leaves the program in that state. If one of the words INIT, INPUT, TRANS, or PROC appears in the column, the command is accepted in the program state indicated by the column heading, but it moves the program into the state indicated by INIT, INPUT, TRANS, or PROC. Asterisks in a column indicate errors when the program encounters the command in that program state. Commands marked with the dagger (†) in the column for the procedure state clear the active dataset.
The table shows six groups of commands: utility, file definition, input program, data transformation, restricted transformation, and procedure commands. These groups are discussed in the following sections.
To read the table, first locate the command. If you simply want to know where in the command stream it can go, look for columns without asterisks. For example, the COMPUTE command can be used when the program is in the input program state, the transformation state, or the procedure state, but it will cause an error if you try to use it in the initial state. If you want to know what can follow a command, look at each of the four columns next to the command. If the column is dashed, any commands not showing asterisks in the column for that program state can follow the command. If the column contains one of the words INIT, INPUT, TRANS, or PROC, any command not showing asterisks in the column for the program state indicated by that word can follow the command.
For example, if you want to know what commands can follow the INPUT PROGRAM command, note first that it is allowed only in the initial or procedure states. Then note that INPUT PROGRAM puts the program into the input program state wherever it occurs legally. This means that commands with dashes or words in the INPUT column can follow the INPUT PROGRAM command. This includes all the utility commands, the DATA LIST command, input program commands, and transformation commands like COMPUTE. Commands that are not allowed after the INPUT PROGRAM command are most of the file definition commands that are their own input program (such as GET), restricted transformations (such as SELECT IF), and procedures.
INIT | INPUT | TRANS | PROC | |
---|---|---|---|---|
Utility commands | ||||
CLEAR TRANSFORMATIONS | ** | PROC | PROC | — |
COMMENT | — | — | — | — |
DISPLAY | ** | — | — | — |
DOCUMENT | ** | — | — | — |
DROP DOCUMENTS | ** | — | — | — |
END DATA | — | — | — | — |
ERASE | — | — | — | — |
FILE HANDLE | — | — | — | — |
FILE LABEL | — | — | — | — |
FINISH | — | — | — | — |
INCLUDE | — | — | — | — |
INFO | — | — | — | — |
DEFINE—!ENDDEFINE | — | — | — | — |
N OF CASES | — | — | — | TRANS |
NEW FILE | — | INIT | INIT | INIT† |
PROCEDURE OUTPUT | — | — | — | — |
SET, SHOW | — | — | — | — |
TITLE, SUBTITLE | — | — | — | — |
File definition commands | ||||
ADD FILES | TRANS | ** | — | TRANS |
DATA LIST | TRANS | — | INPUT | TRANS† |
FILE TYPE | INPUT | ** | INPUT | INPUT† |
GET | TRANS | ** | — | TRANS† |
GET CAPTURE | TRANS | ** | — | TRANS† |
GET SAS | TRANS | ** | — | TRANS† |
GET TRANSLATE | TRANS | ** | — | TRANS† |
IMPORT | TRANS | ** | — | TRANS† |
INPUT PROGRAM | TRANS | ** | — | TRANS† |
KEYED DATA LIST | TRANS | — | — | TRANS |
MATCH FILES | TRANS | ** | — | TRANS |
MATRIX DATA | TRANS | ** | — | TRANS† |
RENAME VARIABLES | ** | — | — | TRANS |
UPDATE | TRANS | ** | — | TRANS |
Input program commands | ||||
END CASE | ** | — | ** | ** |
END FILE | ** | — | ** | ** |
END FILE TYPE | ** | TRANS | ** | ** |
END INPUT PROGRAM | ** | TRANS | ** | ** |
POINT | ** | — | ** | ** |
RECORD TYPE | ** | — | ** | ** |
REPEATING DATA | ** | — | ** | ** |
REREAD | ** | — | ** | ** |
Transformation commands | ||||
ADD VALUE LABELS | ** | — | — | TRANS |
APPLY DICTIONARY | ** | — | — | TRANS |
COMPUTE | ** | — | — | TRANS |
COUNT | ** | — | — | TRANS |
DO IF—END IF | ** | — | — | TRANS |
DO REPEAT—END REPEAT | ** | — | — | TRANS |
ELSE | ** | — | — | TRANS |
ELSE IF | ** | — | — | TRANS |
FORMATS | ** | — | — | TRANS |
IF | ** | — | — | TRANS |
LEAVE | ** | — | — | TRANS |
LOOP—END LOOP, BREAK | ** | — | — | TRANS |
MISSING VALUES | ** | — | — | TRANS |
NUMERIC | ** | — | — | TRANS |
** | — | — | TRANS | |
PRINT EJECT | ** | — | — | TRANS |
PRINT FORMATS | ** | — | — | TRANS |
PRINT SPACE | ** | — | — | TRANS |
RECODE | ** | — | — | TRANS |
SPLIT FILE | ** | — | — | TRANS |
STRING | ** | — | — | TRANS |
VALUE LABELS | ** | — | — | TRANS |
VARIABLE LABELS | ** | — | — | TRANS |
VECTOR | ** | — | — | TRANS |
WEIGHT | ** | — | — | TRANS |
WRITE | ** | — | — | TRANS |
WRITE FORMATS | ** | — | — | TRANS |
XSAVE | ** | — | — | TRANS |
Restricted transformations | ||||
FILTER | ** | ** | — | TRANS |
REFORMAT | ** | ** | — | TRANS |
SAMPLE | ** | ** | — | TRANS |
SELECT IF | ** | ** | — | TRANS |
TEMPORARY | ** | ** | — | TRANS |
Procedures | ||||
BEGIN DATA | ** | ** | PROC | — |
EXECUTE | ** | ** | PROC | — |
EXPORT | ** | ** | PROC | — |
GRAPH | ** | ** | PROC | — |
LIST | ** | ** | PROC | — |
SAVE | ** | ** | PROC | — |
SAVE TRANSLATE | ** | ** | PROC | — |
SORT CASES | ** | ** | PROC | — |
other procedures | ** | ** | PROC | — |