1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
*(Q) Using CTABLES, if I ask respondents to espress their preferences about a
 colors, the left-most column of the table I generate *should* look like:

YELLOW  50
GREEN   40
BLUE    30
RED     10
OTHERS  35

And *not* like it happens rights now:

YELLOW  50
GREEN   40
OTHERS  35
BLUE    30
RED     10

Any suggestion on how I can achieve that result?

*(A) Posted to SPSSX-L list by Raynald Levesque on 2003/05/02.

DATA LIST LIST /color(A8) wgt(F8).
BEGIN DATA
YELLOW  50
GREEN   40
OTHERS  35
BLUE    30
RED     10
END DATA.

WEIGHT BY wgt.
COMPUTE cnt=1.

IF color="OTHERS" cnt=-1.
* next custom format will hide the negative signs of cnt.
* The negative value ensures that OTHERS is the last category listed.
SET CCA=',,,'.
FORMATS cnt (CCA4).

* Custom Tables.
CTABLES
  /VLABELS VARIABLES=cnt color DISPLAY=DEFAULT
  /TABLE color BY cnt [SUM 'Count' CCA40.0]
  /CATEGORIES VARIABLES=color ORDER=D KEY=SUM(cnt) EMPTY=EXCLUDE
  /TITLES TITLE="By decreasing count but" "with OTHERS as last".