Overview (OUTPUT NAME command)

The OUTPUT commands (OUTPUT NEW, OUTPUT NAME, OUTPUT ACTIVATE, OUTPUT OPEN, OUTPUT SAVE, OUTPUT CLOSE) provide the ability to programmatically manage one or many output documents. These functions allow you to:

  • Save an output document through syntax.
  • Programmatically partition output into separate output documents (for example, results for males in one output document and results for females in a separate one).
  • Work with multiple open output documents in a given session, selectively appending new results to the appropriate document.

The OUTPUT NAME command assigns a name to the designated output document. The designated output document is the one most recently opened (by OUTPUT NEW or OUTPUT OPEN) or activated (by OUTPUT ACTIVATE). The document name is used to reference the document in any subsequent OUTPUT ACTIVATE, OUTPUT SAVE, and OUTPUT CLOSE commands.

Basic Specification

The basic specification for OUTPUT NAME is the command name followed by a name that conforms to variable naming rules. See the topic Variable Names for more information. The NAME keyword is optional, but if it is used it must be followed by an equals sign.

Operations

  • The association with the existing name is broken, and the new name is assigned to the document.
  • If the specified name is associated with another document, that association is broken and the name is associated with the designated output document. The document previously associated with the specified name is assigned a new unique name.

Example

GET FILE='/examples/data/SurveyData.sav'.

TEMPORARY.
SELECT IF (Sex='Male').
FREQUENCIES VARIABLES=ALL.
OUTPUT NAME males.

TEMPORARY.
SELECT IF (Sex='Female').
OUTPUT NEW NAME=females.
FREQUENCIES VARIABLES=ALL.

GET FILE='/examples/data/Preference.sav'.

TEMPORARY.
SELECT IF (Sex='Female').
DESCRIPTIVES VARIABLES=product1 product2 product3.

TEMPORARY.
SELECT IF (Sex='Male').
OUTPUT ACTIVATE males.
DESCRIPTIVES VARIABLES=product1 product2 product3.

OUTPUT SAVE NAME=males OUTFILE='/examples/output/Males.spv'.
OUTPUT SAVE NAME=females OUTFILE='/examples/output/Females.spv'.
  • The first GET command loads survey data for males and females.
  • FREQUENCIES output for male respondents is written to the designated output document. The OUTPUT NAME command is used to assign the name males to the designated output document.
  • FREQUENCIES output for female respondents is written to a new output document named females.
  • The second GET command loads preferences data for males and females.
  • Descriptive statistics for females are appended to the output document named females and those for males are appended to the output document named males. Each output document now contains both survey and preferences results.
  • The two open output documents are saved to separate files. Because the operation of saving an output document does not close it, both documents remain open. The output document named males remains the designated output document.