Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Assuming there are no numbers in the characters for which you want to count x's, you can use this DFSORT job to do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
aaaaxxaaaaaxxxx
aaaaaaffdfxmm
dddddxxxdddddd
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
* Change 'x' to '1'
ALTSEQ CODE=(A7F1)
* Copy 1-15 to 21-35 and change each 'x' to a '1' in 21-35.
INREC FIELDS=(1,15,21:1,15,TRAN=ALTSEQ)
* Get total of 1s in 21-35 (with FS, letters will be treated as 0).
OUTREC FIELDS=(1,15,X,
21,1,FS,ADD,22,1,FS,ADD,23,1,FS,ADD,24,1,FS,ADD,25,1,FS,ADD,
26,1,FS,ADD,27,1,FS,ADD,28,1,FS,ADD,29,1,FS,ADD,30,1,FS,ADD,
31,1,FS,ADD,32,1,FS,ADD,33,1,FS,ADD,34,1,FS,ADD,35,1,FS,
TO=FS,LENGTH=3)
/*
|
SORTOUT will have:
Code: |
aaaxxaaaaaxxxx 6
aaaaaffdfxmm 1
ddddxxxdddddd 3
|
If there are numbers in the characters for which you want to count x's, change the ALTSEQ statement to:
Code: |
ALTSEQ CODE=(A7F1,F1F0,F2F0,F3F0,F4F0,F5F0,F6F0,F7F0,F8F0,F9F0)
|
This will ensure that numbers are counted as 0s and only x's are counted as 1s. |
|