CASENUM:  Giving a label for sorting purposes


Return to Previous Page (Desc. Stats)

It is important to be easily able to get back to the original order of cases, so you can feel free to sort whenever this is indicated, then
get back to the original order without worrying. Most files are initially sorted by the identifying code (e.g. household and child numbers),
and if not it’s worth doing this to begin with. It’s useful though to have a sequential numbering of cases.

The easy way to do this:

1. Insert a new variable at the beginning of the file by clicking on the name of the first column to highlight the column and then clicking on Data, Insert Variable.

2. Label this variable CASENUM by double clicking on the new variable column to enter the Define Variable field.

3.  Compute the new variable by clicking on Transform, Compute and enter Casenum in the Target Variable box.

4.  In the Numeric Expression box, enter the following : casenum/= $CASENUM. ($CASENUM is the system variable hidden in there that is the same as the row numbering). This then duplicates the row number — and you can always get back to the original order by sorting on CASENUM (ascending).

You’ll feel freer to use sort as a tool this way — for example to look at extreme values of a variable.