### 6.5 Order of Commands

pspp does not place many restrictions on ordering of commands. The main restriction is that variables must be defined before they are otherwise referenced. This section describes the details of command ordering, but most users will have no need to refer to them.

pspp possesses five internal states, called initial, input-program file-type, transformation, and procedure states. (Please note the distinction between the `INPUT PROGRAM` and `FILE TYPE` commands and the input-program and file-type states.)

pspp starts in the initial state. Each successful completion of a command may cause a state transition. Each type of command has its own rules for state transitions:

Utility commands
  - Valid in any state.
  - Do not cause state transitions. Exception: when `N OF CASES` is executed in the procedure state, it causes a transition to the transformation state.
`DATA LIST`
  - Valid in any state.
  - When executed in the initial or procedure state, causes a transition to the transformation state.
  - Clears the active dataset if executed in the procedure or transformation state.
`INPUT PROGRAM`
  - Invalid in input-program and file-type states.
  - Causes a transition to the intput-program state.
  - Clears the active dataset.
`FILE TYPE`
  - Invalid in intput-program and file-type states.
  - Causes a transition to the file-type state.
  - Clears the active dataset.
Other file definition commands
  - Invalid in input-program and file-type states.
  - Cause a transition to the transformation state.
  - Clear the active dataset, except for `ADD FILES`, `MATCH FILES`, and `UPDATE`.
Transformations
  - Invalid in initial and file-type states.
  - Cause a transition to the transformation state.
Restricted transformations
  - Invalid in initial, input-program, and file-type states.
  - Cause a transition to the transformation state.
Procedures
  - Invalid in initial, input-program, and file-type states.
  - Cause a transition to the procedure state.