|
SORT2Name:
In the variable list, the sorts are performed from left to right. For example, if we are sorting the variables X and Y, we first sort the X variable (and carry the corresponding rows in Y). We then determine the distinct values in the X array. For each distinct value of X, we sort the corresponding rows in the Y variable.
<SUBSET/EXCEPT/FOR qualification> where <x1> is the first variable to be sorted; <x2> is the second variable to be sorted; <y1> is a variable where the sorted <x1> values are saved; <y2> is a variable where the sorted <x2> values are saved; and where the <SUBSET/EXCEPT/FOR qualification> is optional. This syntax is used for the case where we are sorting based on two variables.
<SUBSET/EXCEPT/FOR qualification> where <x1> is the first variable to be sorted; <x2> is the second variable to be sorted; <x3> is the third variable to be sorted; <y1> is a variable where the sorted <x1> values are saved; <y2> is a variable where the sorted <x2> values are saved; <y3> is a variable where the sorted <x3> values are saved; and where the <SUBSET/EXCEPT/FOR qualification> is optional. This syntax is used for the case where we are sorting based on three variables.
<SUBSET/EXCEPT/FOR qualification> where <x1> is the first variable to be sorted; <x2> is the second variable to be sorted; <x3> is the third variable to be sorted; <x4> is the fourth variable to be sorted; <y1> is a variable where the sorted <x1> values are saved; <y2> is a variable where the sorted <x2> values are saved; <y3> is a variable where the sorted <x3> values are saved; <y4> is a variable where the sorted <x4> values are saved; and where the <SUBSET/EXCEPT/FOR qualification> is optional. This syntax is used for the case where we are sorting based on four variables.
LET Y1 Y2 Y3 = SORT3 X1 X2 X3 LET Y1 Y2 Y3 Y4 = SORT3 X1 X2 X3 X4
Currently, all variables must be sorted in the same direction (i.e., either ascending or descending).
SKIP 25 READ GEAR.DAT Y X LET X2 Y2 = SORT2 X Y SET WRITE DECIMALS 3 PRINT X Y X2 Y2The following output is generated. VARIABLES--X Y X2 Y2 1.000 1.006 1.000 0.992 1.000 0.996 1.000 0.993 1.000 0.998 1.000 0.994 1.000 1.000 1.000 0.996 1.000 0.992 1.000 0.998 1.000 0.993 1.000 0.999 1.000 1.002 1.000 1.000 1.000 0.999 1.000 1.000 1.000 0.994 1.000 1.002 1.000 1.000 1.000 1.006 2.000 0.998 2.000 0.988 2.000 1.006 2.000 0.996 2.000 1.000 2.000 0.997 2.000 1.002 2.000 0.998 2.000 0.997 2.000 0.998 2.000 0.998 2.000 1.000 2.000 0.996 2.000 1.000 2.000 1.000 2.000 1.002 2.000 1.006 2.000 1.006 2.000 0.988 2.000 1.006 3.000 0.991 3.000 0.987 3.000 0.987 3.000 0.991 3.000 0.997 3.000 0.994 3.000 0.999 3.000 0.995 3.000 0.995 3.000 0.996 3.000 0.994 3.000 0.996 3.000 1.000 3.000 0.997 3.000 0.999 3.000 0.999 3.000 0.996 3.000 0.999 3.000 0.996 3.000 1.000 4.000 1.005 4.000 0.994 4.000 1.002 4.000 0.994 4.000 0.994 4.000 0.995 4.000 1.000 4.000 0.996 4.000 0.995 4.000 0.996 4.000 0.994 4.000 0.998 4.000 0.998 4.000 1.000 4.000 0.996 4.000 1.002 4.000 1.002 4.000 1.002 4.000 0.996 4.000 1.005 5.000 0.998 5.000 0.980 5.000 0.998 5.000 0.982 5.000 0.982 5.000 0.984 5.000 0.990 5.000 0.990 5.000 1.002 5.000 0.993 5.000 0.984 5.000 0.996 5.000 0.996 5.000 0.996 5.000 0.993 5.000 0.998 5.000 0.980 5.000 0.998 5.000 0.996 5.000 1.002 6.000 1.009 6.000 0.981 6.000 1.013 6.000 0.988 6.000 1.009 6.000 0.995 6.000 0.997 6.000 0.996 6.000 0.988 6.000 0.997 6.000 1.002 6.000 0.998 6.000 0.995 6.000 1.002 6.000 0.998 6.000 1.009 6.000 0.981 6.000 1.009 6.000 0.996 6.000 1.013 7.000 0.990 7.000 0.990 7.000 1.004 7.000 0.996 7.000 0.996 7.000 0.996 7.000 1.001 7.000 0.998 7.000 0.998 7.000 1.000 7.000 1.000 7.000 1.001 7.000 1.018 7.000 1.002 7.000 1.010 7.000 1.004 7.000 0.996 7.000 1.010 7.000 1.002 7.000 1.018 8.000 0.998 8.000 0.996 8.000 1.000 8.000 0.996 8.000 1.006 8.000 0.998 8.000 1.000 8.000 0.998 8.000 1.002 8.000 1.000 8.000 0.996 8.000 1.000 8.000 0.998 8.000 1.002 8.000 0.996 8.000 1.002 8.000 1.002 8.000 1.006 8.000 1.006 8.000 1.006 9.000 1.002 9.000 0.991 9.000 0.998 9.000 0.995 9.000 0.996 9.000 0.996 9.000 0.995 9.000 0.996 9.000 0.996 9.000 0.998 9.000 1.004 9.000 0.998 9.000 1.004 9.000 0.999 9.000 0.998 9.000 1.002 9.000 0.999 9.000 1.004 9.000 0.991 9.000 1.004 10.000 0.991 10.000 0.984 10.000 0.995 10.000 0.991 10.000 0.984 10.000 0.991 10.000 0.994 10.000 0.994 10.000 0.997 10.000 0.995 10.000 0.997 10.000 0.997 10.000 0.991 10.000 0.997 10.000 0.998 10.000 0.997 10.000 1.004 10.000 0.998 10.000 0.997 10.000 1.004Program 2: SKIP 25 READ RIPKEN.DAT Y X1 X2 X3 X4 LET Z2 Z3 Y2 = SORT3 X2 X3 Y SET WRITE FORMAT 2(2F5.0,F9.3) PRINT X2 X3 Y Z2 Z3 Y2 LET Z2 Z3 Z4 Y2 = SORT3 X2 X3 X4 Y SET WRITE FORMAT 2(3F5.0,F9.3) PRINT X2 X3 X4 Y Z2 Z3 Z4 Y2The following output is generated. X1 X2 Y Z1 Z2 Y2 1. 1. 0.400 1. 1. 0.086 2. 1. 0.354 1. 1. 0.136 3. 1. 0.388 1. 1. 0.333 1. 1. 0.380 1. 1. 0.380 2. 1. 0.409 1. 1. 0.382 3. 1. 0.391 1. 1. 0.400 1. 1. 0.136 1. 2. 0.162 2. 1. 0.322 1. 2. 0.166 3. 1. 0.304 1. 2. 0.166 1. 2. 0.166 1. 2. 0.166 2. 2. 0.333 1. 2. 0.300 3. 2. 0.000 1. 2. 0.300 1. 2. 0.300 2. 1. 0.280 2. 2. 0.875 2. 1. 0.322 3. 2. 1.000 2. 1. 0.350 1. 2. 0.166 2. 1. 0.354 2. 2. 0.090 2. 1. 0.373 3. 2. 0.333 2. 1. 0.409 1. 1. 0.382 2. 2. 0.090 2. 1. 0.373 2. 2. 0.211 3. 1. 0.223 2. 2. 0.333 1. 1. 0.333 2. 2. 0.363 2. 1. 0.350 2. 2. 0.454 3. 1. 0.304 2. 2. 0.875 1. 1. 0.086 3. 1. 0.218 2. 1. 0.280 3. 1. 0.223 3. 1. 0.218 3. 1. 0.304 1. 2. 0.166 3. 1. 0.304 2. 2. 0.363 3. 1. 0.388 3. 2. 0.333 3. 1. 0.391 1. 2. 0.300 3. 2. 0.000 2. 2. 0.454 3. 2. 0.000 3. 2. 0.285 3. 2. 0.285 1. 2. 0.162 3. 2. 0.333 2. 2. 0.211 3. 2. 0.333 3. 2. 0.000 3. 2. 1.000 X1 X2 X3 Y Z1 Z2 Z3 Y2 1. 1. 1. 0.400 1. 1. 1. 0.136 2. 1. 1. 0.354 1. 1. 1. 0.380 3. 1. 1. 0.388 1. 1. 1. 0.400 1. 1. 1. 0.380 1. 1. 2. 0.086 2. 1. 1. 0.409 1. 1. 2. 0.333 3. 1. 1. 0.391 1. 1. 2. 0.382 1. 1. 1. 0.136 1. 2. 1. 0.166 2. 1. 1. 0.322 1. 2. 1. 0.166 3. 1. 1. 0.304 1. 2. 1. 0.300 1. 2. 1. 0.166 1. 2. 2. 0.162 2. 2. 1. 0.333 1. 2. 2. 0.166 3. 2. 1. 0.000 1. 2. 2. 0.300 1. 2. 1. 0.300 2. 1. 1. 0.322 2. 2. 1. 0.875 2. 1. 1. 0.354 3. 2. 1. 1.000 2. 1. 1. 0.409 1. 2. 1. 0.166 2. 1. 2. 0.280 2. 2. 1. 0.090 2. 1. 2. 0.350 3. 2. 1. 0.333 2. 1. 2. 0.373 1. 1. 2. 0.382 2. 2. 1. 0.090 2. 1. 2. 0.373 2. 2. 1. 0.333 3. 1. 2. 0.223 2. 2. 1. 0.875 1. 1. 2. 0.333 2. 2. 2. 0.211 2. 1. 2. 0.350 2. 2. 2. 0.363 3. 1. 2. 0.304 2. 2. 2. 0.454 1. 1. 2. 0.086 3. 1. 1. 0.304 2. 1. 2. 0.280 3. 1. 1. 0.388 3. 1. 2. 0.218 3. 1. 1. 0.391 1. 2. 2. 0.166 3. 1. 2. 0.218 2. 2. 2. 0.363 3. 1. 2. 0.223 3. 2. 2. 0.333 3. 1. 2. 0.304 1. 2. 2. 0.300 3. 2. 1. 0.000 2. 2. 2. 0.454 3. 2. 1. 0.333 3. 2. 2. 0.285 3. 2. 1. 1.000 1. 2. 2. 0.162 3. 2. 2. 0.000 2. 2. 2. 0.211 3. 2. 2. 0.285 3. 2. 2. 0.000 3. 2. 2. 0.333
Date created: 10/15/2008 |