Join Files on Country Code and Summarize by Region

Input File 1 
US 100
UK  50
GR   1
US  39
ES  90
CN  29
GR   3
MX  44
UK  12
JP   5
Input File 2
ES Spain           Europe
UK United Kingdom  Europe
MX Mexico          North America
US United States   North America
GR Greece          Europe
CN China           Asia
JP Japan           Asia
Sort Control Cards
 JOINKEYS FILE=F1,FIELDS=(1,2,A) * sales
 JOINKEYS FILE=F2,FIELDS=(1,2,A) * country code file
 REFORMAT FIELDS=(F2:20,16,F1:3,4) * Copy Region to sales
 SORT FIELDS=(1,16,CH,A) * Sort by Region
 SUM FIELDS=(17,4,ZD)
 END
Output File
Asia              34
Europe           156
North America    183
Back to Examples