FILE SORT <data file> BY <list of sort keys> TO <new data file> where <list of sort keys> has the form <field 1>,<field 2>,... sorts the observations of <data file> in the order specified by <list of sort keys> and places the sorted data to <new data file>. In <list of sort keys> <field 1> is the primary sort key, <field 2> the secondary one, etc. In case of a numeric field (sort key) the data is sorted in ascending order. However, a '-' in front of the sort key causes the data to be sorted in descending order. In case of a string field as a sort key, any part of the field can be used by indicating the first and last byte in the form <name_of the_field>[<first_byte>:<last_byte>]. For example, FILE SORT COMMUNES BY Province[1:3],-People TO B:COMSORT sorts the data in COMMUNES primarily with respect to counties using the 3 first letters as the sort key and then within the counties in descending order with respect of 'People'. In case of ties the original order will be preserved. If string fields appear as a part of the sort key, the characters are sorted according to the order specified by a FILTER=<code_file> specification. In <code_file> the complete pathname must be given. Default is FILTER=SORTCODE.BIN which equates lower case letters to upper case ones. You may study existing code files (extension .BIN) and create new code files by using the CODES SAVE and CODES LOAD operations. If no cases are active, an error message is displayed. This message is avoided and an empty <new data file> created by specification SAVE=1. As an option, a limited number of the records in the sorted data are moved to <new data file>. By giving NSORT=k, only k first of the sorted records are moved. This is an useful option when FILE SORT is used for taking random samples. Then random variable, say R, is computed by VAR R=rnd(0) and the data is sorted with respect of R by FILE SORT <data file> BY R TO <new data file> / NSORT=<samplesize> F = Additional specifications for space allocation & intermediate files D = More information on data management C = CODES operations S = Sorting of lines in the edit field A = Saving the sort keys