SELECT operator

Read syntax diagramSkip visual syntax diagram
>>-SELECT--FROM(indd)--+-TO(outdd)------------------+----------->
                       +-DISCARD(savedd)------------+   
                       '-TO(outdd)--DISCARD(savedd)-'   

   .---------------.                                     
   V               |                                     
>----+-ON(p,m,f)-+-+--+-ALLDUPS-----+--+-------------+---------->
     '-ON(VLEN)--'    +-NODUPS------+  '-VSAMTYPE(x)-'   
                      +-HIGHER(x)---+                    
                      +-LOWER(y)----+                    
                      +-EQUAL(v)----+                    
                      +-FIRST-------+                    
                      +-FIRST(u)----+                    
                      +-LAST--------+                    
                      +-FIRSTDUP----+                    
                      +-FIRSTDUP(w)-+                    
                      '-LASTDUP-----'                    

>--+-------+--+-------------+----------------------------------><
   '-UZERO-'  '-USING(xxxx)-'   

Selects records from an input data set based on meeting criteria for the number of times specified numeric or character field values occur. This makes it possible to only keep records with duplicate field values, only keep records with no duplicate field values, only keep records with field values that occur more than, less than, or exactly n times, only keep the first or first n duplicate records with each field value, or only keep the first or last record with each unique or duplicate field value. From 1 to 10 fields can be specified. At least one ON(VLEN) or ON(p,m,f) field must be specified; all such ON fields specified will be used to determine the "value count" (that is, the number of times the ON values occur) to be matched against the criteria.

DISCARD(savedd) can be used to save the records that do not meet the criteria (that is, the discarded records), in the savedd data set. DISCARD(savedd) can be used with or without TO(outdd).

DFSORT is called to sort the indd data set. ICETOOL uses its E35 exit to determine which records to include in the outdd data set or savedd data set. ICETOOL passes the EQUALS option to DFSORT to ensure that duplicates are kept in their original input order.

The DFSORT control statements in xxxxCNTL are used if USING(xxxx) is specified.

Do not supply your own MODS, SUM or OUTREC statement.

You can use comment statements. You can use INCLUDE, OMIT, INREC, OPTION, SORT, or OUTFIL statements providing you observe these rules:
  • You can use an INCLUDE or OMIT statement to remove input records before SELECT processing.
  • You can use an INREC statement to reformat input records before SELECT processing. You can use INREC's PARSE, BUILD (FIELDS), OVERLAY, FINDREP, IFTHEN, or IFOUTLEN functions. If your INREC statement changes the starting position of an ON field, you must specify the new starting position for that ON field. For example, if your input records have a CH key at positions 1-5 and you use an INREC statement like this:
      INREC FIELDS=(25:1,50)
    you must specify ON(25,5,CH) instead of ON(1,5,CH).
  • If you specify a SORT statement, you must specify each ON field as a p,m,f,A sort field and these sort fields must be in the same order as the ON fields. After these sort fields, you can specify additional p,m,f,A or p,m,f,D sort fields. The additional sort fields will be used for sorting, but not for selecting. For example, if you use a SELECT statement like this:
      SELECT FROM(IN) TO(OUT) ON(21,5,CH) FIRST(3) USING(CTL1)  
    you can use a SORT statement in CTL1CNTL like this:
      SORT FIELDS=(21,5,CH,A,41,6,CH,D)
    The records will be sorted by the 21,5,CH,A field and the 41,6,CH,D field, but only selected by the 21,5,CH field. This would allow you to select the three highest 41,6,CH values for each 21,5,CH value.
  • If you specify TO(outdd) without DISCARD(savedd), you can further process the outdd records after SELECT processing using an OUTFIL statement like this:
      OUTFIL FNAMES=outdd,...
    or multiple OUTFIL statements like this:
      OUTFIL FNAMES=outdd,...
      OUTFIL FNAMES=outdd1,...
      ...
  • If you specify DISCARD(savedd) without TO(outdd), you can further process the savedd records after SELECT processing using one (and only one) OUTFIL statement like this:
      OUTFIL FNAMES=savedd,...
  • If you specify TO(outdd) and DISCARD(savedd), you can further process the outdd and savedd records after SELECT processing using two (and only two) OUTFIL statements like this:
      OUTFIL FNAMES=outdd,...
      OUTFIL FNAMES=savedd,...
    Both statements must be specified in the order shown with at least the FNAMES parameter. For example, to further modify only the DISCARD data set, you could use statements like this:
     OUTFIL FNAMES=OUT
     OUTFIL FNAMES=SAVE,INCLUDE=(21,3,ZD,GT,+25)

ICETOOL requires extra storage for SELECT processing, over and above what is normally needed by ICETOOL and DFSORT, in order to save your records until it can determine whether or not they meet your specified criteria. In most cases, only a small amount of storage is needed and can be obtained (above 16MB virtual). However, for a FROM data set with a large record length and criteria requiring many saved records, a large amount of storage is needed. For example, with a record length of 32756 and HIGHER(99), over 3 MBs of storage is needed. If ICETOOL cannot get the storage it needs, it issues a message and terminates the SELECT operation. Increasing the REGION by the amount indicated in the message may allow ICETOOL to run successfully.

The DYNALLOC option is passed to DFSORT to ensure that work space is available for the sort. If your installation defaults for dynamic allocation are inappropriate for a SELECT operator, you can specify USING(xxxx) and take one of the following actions:
  1. Override the DYNALLOC option using an OPTION control statement such as:
         OPTION DYNALLOC=(,8)

    in the xxxxCNTL data set.

  2. Use xxxxWKdd DD statements to override the use of dynamic allocation. Refer to SORTWKdd DD statement for details.

Tape work data sets cannot be used with ICETOOL.