27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

396 CTABLES<br />

• Summary functions available only for scale variables require that you give the variable<br />

name in parentheses, as in MEAN(AGE). Other functions, such as COUNT, do not require<br />

a variable name, but you can supply one to restrict the sort.<br />

• When a variable name is given and multiple logical tables are created through stacking,<br />

the entire table is sorted based on the first logical table that includes the categorical variable<br />

being sorted and the variable specified in the key.<br />

• When a table contains more than one dimension, the sort is based on the distribution of<br />

the key within the categories of the sorted variable without regard to the contents of the<br />

other dimensions. Thus, given the table<br />

CTABLES /TABLE A BY B + C /CAT VAR=A ORDER=A KEY=COUNT(A),<br />

the rows are sorted according to the counts for the categories of A without regard to the<br />

values of B and C. If there are no missing values in the other dimension, the result is the<br />

same as sorting on the totals for that dimension, in this case B or C. If the other dimension<br />

has an unbalanced pattern of missing values, the sorting may give unexpected results;<br />

however, the result is unaffected by differences in the pattern for B and C.<br />

• If the sort variable is crossed with stacked category variables, the first table in the stack<br />

determines the sort order.<br />

• To ensure that the categories are sorted the same way in each layer of the pivot table, layer<br />

variables are ignored for the purpose of sorting.<br />

Example<br />

CTABLES<br />

/TABLE CAR1 BY AGECAT<br />

/CATEGORIES VARIABLES=AGECAT TOTAL=YES<br />

/CATEGORIES VARIABLES=CAR1 ORDER=D KEY=COUNT.<br />

Car<br />

maker,<br />

most<br />

recent<br />

car<br />

American<br />

Japanese<br />

German<br />

Korean<br />

Swedish<br />

Other<br />

Age category<br />

Less than<br />

25 25 to 34 35 to 44 45 to 54 55 to 64 65 or older Total<br />

Count Count Count Count Count Count Count<br />

99 267 293 214 140 215 1228<br />

73 136 140 107 66 104 626<br />

18 91 69 63 36 61 338<br />

23 77 88 45 35 50 318<br />

18 32 46 20 24 25 165<br />

11 24 43 32 19 24 153<br />

• The first CATEGORIES subcommand requests a total across all age categories.<br />

• The second CATEGORIES subcommand requests a sort of the categories of CAR1 in<br />

descending order using COUNT as the key. The categories of CAR1 are sorted according<br />

to the total counts.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!