WRITE subcommand (CROSSTABS command)
Use the WRITE
subcommand to write cell frequencies to a file for subsequent use
by the current program or another program. CROSSTABS
can also use these cell frequencies as input
to reproduce tables and compute statistics. When WRITE
is specified, an Output File Summary table is displayed
before all other tables. See the OMS command for alternative and more
flexible methods for writing out results to external files in various
formats.
- The only specification is a single keyword.
- The name of the file must be specified on the
PROCEDURE OUTPUT
command precedingCROSSTABS
. - If you include missing values with
INCLUDE
orREPORT
onMISSING
, no values are considered missing and all non-empty cells, including those with missing values, are written, even ifCELLS
is specified. - If you exclude missing values on a table-by-table basis (the default), no records are written for combinations of values that include a missing value.
- If multiple tables are specified, the tables are written in the same order as they are displayed.
-
WRITE
is not supported for long string variables (defined width greater than 8 bytes) and will result in an error if any of the variables are long strings. -
WRITE
is not supported for tables with more than eight dimensions (seven BY variables) and will result in an error if the table has more than eight dimensions.
NONE. Do not write cell counts to a file. This is the default.
CELLS. Write cell counts for non-empty and nonmissing cells to a file. Combinations of values that include a missing value are not written to the file.
ALL. Write cell
counts for all cells to a file. A record for each combination
of values defined by VARIABLES
and TABLES
is written to the
file. ALL
is available only
in integer mode.
The file contains one record for each cell. Each record contains the following:
Columns 1–4. Split-file group number, numbered consecutively from 1. Note that this is not the value of the variable or variables used to define the splits.
Columns 5–8. Table number. Tables are defined by the TABLES
subcommand.
Columns 9–16. Cell frequency. The number of times this combination of variable values occurred in the data, or, if case weights are used, the sum of case weights for cases having this combination of values.
Columns 17–24. The value
of the row variable (the one named before the first BY
).
Columns 25–32. The value
of the column variable (the one named after the first
BY
).
Columns 33–40. The value
of the first control variable (the one named after the
second BY
).
Columns 41–48. The value
of the second control variable (the one named after the
third BY
).
Columns 49–56. The value
of the third control variable (the one named after the
fourth BY
).
Columns 57–64. The value
of the fourth control variable (the one named after the
fifth BY
).
Columns 65–72. The value
of the fifth control variable (the one named after the
sixth BY
).
Columns 73–80. The value
of the sixth control variable (the one named after the
seventh BY
).
- The split-file group number, table number, and frequency are written as integers.
- In integer mode, the values of variables are also written as integers. In general mode, the values are written according to the print format specified for each variable. Alphanumeric values are written at the left end of any field in which they occur.
- Within each table, records are written from one column of the table at a time, and the value of the last control variable changes the most slowly.
Example
PROCEDURE OUTPUT OUTFILE='/data/celldata.txt'.
CROSSTABS VARIABLES=FEAR SEX (1,2)
/TABLES=FEAR BY SEX
/WRITE=ALL.
-
CROSSTABS
writes a record for each cell in the table FEAR by SEX to the file celldata.txt.
Example
PROCEDURE OUTPUT OUTFILE='/data/xtabdata.txt'.
CROSSTABS TABLES=V1 TO V3 BY V4 BY V10 TO V15
/WRITE=CELLS.
-
CROSSTABS
writes a set of records for each table to file xtabdata.txt. - Records for the table V1 by V4 by V10 are written first, followed by records for V1 by V4 by V11, and so on. The records for V3 by V4 by V15 are written last.