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.

SORT CASES<br />

SORT CASES [BY] varlist[({A})] [varlist...]<br />

{D}<br />

Example<br />

SORT CASES BY DIVISION (A) STORE (D).<br />

Overview<br />

SORT CASES reorders the sequence of cases in the working data file based on the values of<br />

one or more variables. You can optionally sort cases in ascending or descending order, or<br />

use combinations of ascending and descending order for different variables.<br />

Basic Specification<br />

The basic specification is a variable or list of variables that are used as sort keys. By default,<br />

cases are sorted in ascending order of each variable, starting with the first variable named.<br />

For each subsequent variable, cases are sorted in ascending order within categories of the<br />

previously named variables.<br />

<strong>Syntax</strong> Rules<br />

• Keyword BY is optional.<br />

• BY variables can be numeric or string but not scratch, system, or temporary variables.<br />

• You can explicitly request the default sort order (ascending) by specifying A or UP in<br />

parentheses after the variable name. To sort cases in descending order, specify D or<br />

DOWN.<br />

• An order specification (A or D) applies to all variables in the list up to the previous order<br />

specification. If you combine ascending and descending order on the same SORT CASES<br />

command, you may need to specify the default A explicitly.<br />

Operations<br />

• SORT CASES first sorts the file according to the first variable named. For subsequent<br />

variables, cases are sorted within categories of the previously named variables.<br />

• The sort sequence of string variables depends on the character set in use on your system.<br />

With EBCDIC character sets, most special characters are sorted first, followed by lowercase<br />

alphabetical characters, uppercase alphabetical characters, and, finally, numbers. The<br />

order is almost exactly reversed with ASCII character sets. Numbers are sorted first, followed<br />

by uppercase alphabetical characters and then lowercase alphabetical characters. In<br />

1503

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

Saved successfully!

Ooh no, something went wrong!