Sub-Totaling with Suprtool

Did you know that you can sub-total data with Suprtool, as well as determining how many records made up that total? For example, we can total the number of products sold by product and also total the dollars for each product.

The Duplicate command has a Count Option, whereby you can produce a new field in the output record with the number of occurrences of each key value. The Total Option allows up to 15 fields to be sub-totaled for each duplicate key. For example:

   >base store.demo,5,reader
   >get d-sales              {open a dataset}
   >sort product-no          {define a sort key}
   >duplicate none keys count total sales-qty sales-total
   >out salessum,link        {Output to a link file}
   >xeq
These commands produce a file with a summary by product-no (because that is what we sorted by). The file will contain a count of the number of records for that product-no, and totals for the sales-qty and sales-total.

The count field is called ST-COUNT and the totals have field names of ST-TOTAL-1 and ST-TOTAL-2, which are at the end of each record.

....Back to the Suprtool Q&A Page