FILE AGGR <data> BY <aggr_variable> TO <new_data_file>
allows only one <aggr_variable>.
In certain applications a combination of several variables is needed
for this purpose. Although such a combination can be created by
concatenating string variables (see VARSTR?), a more direct method
is to use a specification
KEY_SAVED=<string_variable>
in the FILE SORT operation which normally precedes FILE AGGR since
the data must be sorted by <aggr_variable>.
KEY_SAVED in FILE SORT creates a <string_variable> if needed
in the <new_data_file> and saves the combined sort keys in it.
All components of the sort key must in this case be string variables.
If not, it is easy to make string variables from numeric ones
(by VAR XS:S3=X TO <data>, for example).
The example on the next page shows how this works with data file
FINLAND.
KEY_SAVED=AIS / Sort keys to be saved as variable AIS
FILE SORT FINLAND BY Agri,Industry,Service TO FIN2
FILE AGGR FIN2 BY AIS TO FIN_AGGR
VARIABLES:
AIS:S3 FIRST AIS
N:2 N -
Mean:4 MEAN Tax
END
................................................................................
FILE LOAD FIN_AGGR / IND=ORDER,1,5 5 first cases loaded
DATA FIN_AGGR*
AIS N Mean
018 2 15.000
027 5 15.700
035 5 16.200
036 10 16.325
044 7 15.657
A = More information on FILE AGGR
D = More information on data management