Example 2

This shows a REXX procedure that copies records and writes type 01 to DD01, type 02 to DD02, type 03 to DD03, and the rest to the default output file. The type starts in column 10 for a length of 2.
  ddname = 'DD'||fld(10,2)        /* DDname for WRITE function */
  if nco(fld(10,2),1,2,3) then do /* does it contain 1,2,3     */
      write(ddname)               /* Yes Write to DDnn         */
      return 'DROP'               /* don't copy to output DD    */
  end
Note: The records that are not processed by the procedure are, by default, copied to the primary output data set.