eric12326,
It would have helped if you posted a sample test data. Looking at your control cards, I gathered that
1- 17 location
18-19 State??
24-25 Month (01-12)
27-33 Sales amount
Now the first SORT is summing sales amount considering Location+ Month as key. If that is the case then you will not get the best performing location as the sum is not considering the State field. for example if you have this data
----+----1----+----2----+----3----+
LOCATION-AAA CA 01 1111111
LOCATION-AAA CA 01 2222222
LOCATION-AAA VA 01 3456789
As you can see the same location and same month have 2 different states. CA and VA. But your SORT would have clubbed all these 3 records together and gave you 1 record as below
LOCATION-AAA CA 01 006790122
Notice how VA location even though has a higher sales amount has completely disappeared. You should also include the field (18,2) as your sort criteria.
So present your input data and desired output and I can a show a much simpler way to do the same task. I would also like to see the level of DFSORT you have. Please run the following job and show me the complete sysout which help us determine the level of DFSORT you have.
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
//*