Controlling Column Elements to Control Variables in the Data File (OMS command)

You can use the COLUMNS subcommand to specify which dimension elements should be in the columns and therefore are used to create variables in the generated data file. This is equivalent to pivoting the table in the Viewer.

Example

The DESCRIPTIVES command produces a table of descriptive statistics with variables in the rows and statistics in the columns. A data file created from that table would therefore use the statistics as variables and the original variables as cases. If you want the original variables to be variables in the generated data file and the statistics to be cases:

OMS 
  /SELECT TABLES
  /IF COMMANDS=['Descriptives'] SUBTYPES=['Descriptive Statistics']
  /DESTINATION FORMAT=SAV OUTFILE='/temp/temp.sav'
  /COLUMNS DIMNAMES=['Variables'].
DESCRIPTIVES VARIABLES=salary salbegin.
OMSEND.
  • When you use the COLUMNS subcommand, any dimension elements not listed on the subcommand will become rows (cases) in the generated data file.
  • Since the descriptive statistics table has only two dimension elements, the syntax COLUMNS DIMNAMES=['Variables'] will put the variables in the columns and will put the statistics in the row. So this is equivalent to swapping the positions of the original row and column elements.
Figure 1. Default and pivoted table and generated data file
Default and pivoted table and generated data file

Example

The FREQUENCIES command produces a descriptive statistics table with statistics in the rows, while the DESCRIPTIVES command produces a descriptive statistics table with statistics in the columns. To include both table types in the same data file in a meaningful fashion, you need to change the column dimension for one of them.

OMS
  /SELECT TABLES
  /IF COMMANDS=['Frequencies' 'Descriptives']
   SUBTYPES=['Statistics' 'Descriptive Statistics']
  /DESTINATION FORMAT=SAV OUTFILE='/temp/temp.sav'
  /COLUMNS DIMNAMES=['Statistics'].
FREQUENCIES
  VARIABLES=salbegin salary  
  /FORMAT=NOTABLE
  /STATISTICS=MINIMUM MAXIMUM MEAN.
DESCRIPTIVES
  VARIABLES=jobtime prevexp
  /STATISTICS=MEAN MIN MAX.
OMSEND.
  • The COLUMNS subcommand will be applied to all selected table types that have a Statistics dimension element.
  • Both table types have a Statistics dimension element, but since it's already in the column dimension for the table produced by the DESCRIPTIVES command, the COLUMNS subcommand has no effect on the structure of the data from that table type.
  • For the FREQUENCIES statistics table, COLUMNS DIMNAMES=['Statistics'] is equivalent to pivoting the Statistics dimension element into the columns and pivoting the Variables dimension element into the rows.
  • Some of the variables will have missing values, since the table structures still aren't exactly the same with statistics in the columns.
Figure 2. Combining different table types in same data file
Combining different table types in same data file