When running commands in SPSS, it routes summaries and output of particular functions to the active Output document. This is very nice for statistical reporting of various tables, like crosstabs or frequencies or nested regression models. This however is not so nice in some circumstances in which the tables are very big. Rendering the output of these large tables takes a fair bit of memory. Also it is near impossible to navigate the tables when they get very large. (I should note SPSS does have some nice pivot table functionality for nested tables, e.g. in CTABLES, but the examples that follow with don’t apply to that.)
A few examples I come across tables being annoying often are:
- Large correlation matrices or distance matrices (which I often export directly to an SPSS file – note
PROXIMITIEShas the option to suppress the table on the command,
- Macro commands that have various data transformations and may produce a series of tables (e.g. VARSTOCASES or CREATE). The regression procedures tend to be the worst offenders, so if you say want the predicted values from a
REGRESSIONor covariances from
FACTORyou get half a dozen other tables along with it.
- Using SPLIT FILE with many groups.
There are basically two ways I know of to easily suppress the output:
- Use the Output Management System (OMS)
SET RESULTS OFF ERRORS OFF.– Via David Marso
It is pretty simple to use either to just suppress the output. For OMS it would be:
OMS /SELECT ALL EXCEPT = [WARNINGS] /DESTINATION VIEWER = NO /TAG = 'NoJunk'. *Your Commands here. OMSEND TAG = 'NoJunk'.
The OMS command just grabs all output except for warnings and tells SPSS to not send it to the output viewer. Per some comments I updated the example to take a TAG subcommand on the OMS command, as this allows you to have multiple OMS statements and only turn off specific ones at a time. Here it is hard to see the utility, but it should be more obvious when we place this inside a macro.
To replace the OMS example with the
SET RESULTS OFF ERRORS OFF. trick by David Marso, you would basically just replace the original
OMS command and then wrap it in
PRESERVE. SET RESULTS OFF ERRORS OFF. *Your Commands here. RESTORE.
Because this changes the system output settings, it is always a good idea to use
PRESERVE and then set the user settings back to what they originally were with
RESTORE. OMS has the slight advantage here that you can set it to still print warning messages. (I do not know off-hand which version of SPSS the OMS command was introduced.)
I will give a pretty simple example of using
CORRELATIONS to suppress such junk output. A question on SO the other day asked about producing all pair-wise correlations above a threshold, and I gave an answer and an example macro to accomplish this (FYI such things would be useful for producing corrgrams or a network diagram of correlations). The output in that example though still produces the correlation table (which in the original posters situation would produce a 200*200 table in the output) and will produce various junk when running the
VARSTOCASES command. Here I wrap the macro in the
OMS statement suppressing the tables and you do not get such junk.
DEFINE !CorrPairs (!POSITIONAL !CMDEND) OMS /SELECT ALL EXCEPT = [WARNINGS] /DESTINATION VIEWER = NO /TAG = "CorrPairs". DATASET DECLARE Corrs. CORRELATIONS /VARIABLES=!1 /MATRIX=OUT('Corrs'). DATASET ACTIVATE Corrs. SELECT IF ROWTYPE_ = "CORR". COMPUTE #iter = 0. DO REPEAT X = !1. COMPUTE #iter = #iter + 1. IF #iter > ($casenum-1) X = $SYSMIS. END REPEAT. VARSTOCASES /MAKE Corr FROM !1 /INDEX X2 (Corr) /DROP ROWTYPE_. RENAME VARIABLES (VARNAME_ = X1). OMSEND TAG="CorrPairs". !ENDDEFINE.
And now using the same example data as I used on the question:
***********************************. *Making fake data. set seed 5. input program. loop i = 1 to 100. end case. end loop. end file. end input program. dataset name test. compute #base = RV.NORMAL(0,1). vector X(20). loop #i = 1 to 20. compute X(#i) = #base*(#i/20) + RV.NORMAL(0,1). end loop. exe. ***********************************. *Now generate correlation pairs. !CorrPairs X1 to X20.
If you want to see all the output that was originally generated just comment out the two lines with the
OMSEND statements in the macro. Newer versions of SPSS limit the number of rows displayed in output tables, so your system shouldn’t crash with newer versions of SPSS even when you have enormous tables. But the advice here still applies, as you might as well route the output for those large tables somewhere else so that they are easier to explore (either using OMS to save the tables or helper functions on certain commands to export tables).