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
PROXIMITIES
has the option to suppress the table on the command,CORRELATIONS
does not). - 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
REGRESSION
or covariances fromFACTOR
you 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)
- Use
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
and RESTORE
statements.
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 OMS
with 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 OMS
and 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).
Jon Peck
/ January 9, 2014Since V21, the memory consumed by large tables is much less than in earlier versions, but OMS can still be used to prevent these tables from ever being sent to the front end. It also has the benefit that the tables can be saved in other formats such as Excel or XML without their ever going to the Viewer. OMS can also route the objects as XML to the in-memory XML workspace where they can be accessed using programmability.
OMS was introduced in SPSS 12, but Office formats and some other features were added later.
If you are writing SPSS code to be used generally, it would be a good idea for the outer wrapper to specify an OMS tag that can be referenced on OMSEND so that any other OMS commands are not affected.
apwheele
/ January 9, 2014Thank you Jon, I never realized you could tag OMS commands like that.
Barry
/ October 6, 2014“If you are writing SPSS code to be used generally, it would be a good idea for the outer wrapper to specify an OMS tag that can be referenced on OMSEND so that any other OMS commands are not affected.”
Jon, how do you tag OMS commands?
apwheele
/ October 7, 2014Hi Barry, I updated the blog post examples to use a tag subcommand. In a nutshell it is just:
********************************.
OMS
/Subcommands
/Tag = “Your Tag”.
*Your syntax.
OMSEND TAG = “Your Tag”.
*********************************.
You can also specify multiple tags on the OMSEND command by placing them in brackets. The help for OMSEND has an example.
Barry
/ October 7, 2014Thank you!