View previous topic :: View next topic
|
Author |
Message |
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
Is there an ICETOOL or SORT statement that will give me the maximum (or mininum) value of a field with FORMAT=CH ? Can this be done without doing a sort on the field? I am looking for just a single value not all of the records. I looked through the manual and could not find one.
The STATS command works only for numeric fields. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
jerryte wrote: |
Is there an ICETOOL or SORT statement that will give me the maximum (or mininum) value of a field with FORMAT=CH ? Can this be done without doing a sort on the field? I am looking for just a single value not all of the records. I looked through the manual and could not find one.
The STATS command works only for numeric fields. |
DFSORT does not have any features to count characters. This can be done by sorting the data and picking the first and last record using Header and trailer. Another alternative is to write an user exit. |
|
Back to top |
|
|
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
Thanks. This would make a good enhancement for the STATS command to return min and max values for a character field.
If I use an INREC to extract just the field I want and then SORT in descending order I can then use an OUTFIL to get the max value. Below is a sample:
Code: |
INREC FIELDS=(87,26)
SORT FIELDS=(1,26,CH,D)
OUTFIL FILES=OUT,ENDREC=1 |
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
jerryte wrote: |
Thanks. This would make a good enhancement for the STATS command to return min and max values for a character field.
If I use an INREC to extract just the field I want and then SORT in descending order I can then use an OUTFIL to get the max value. Below is a sample:
Code: |
INREC FIELDS=(87,26)
SORT FIELDS=(1,26,CH,D)
OUTFIL FILES=OUT,ENDREC=1 |
|
If you can SORT the Field then you can get both MIN and MAX at the same time. Here is a sample for Sorting 10 bytes of character data.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A
AA
AAA
AAAAAAAA
AAAAAAAAA
AAAAAAAAAA
AAAA
AAAAA
AAAAAA
AAAAAAA
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
OUTFIL REMOVECC,NODETAIL,
HEADER1=('MIN VALUE RECORD : ',1,10),
TRAILER1=('MAX VALUE RECORD : ',1,10)
//* |
The output is as follows
Code: |
MIN VALUE RECORD : A
MAX VALUE RECORD : AAAAAAAAAA |
|
|
Back to top |
|
|
|