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:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *
* Change 'x' to '1'
* Copy 1-15 to 21-35 and change each 'x' to a '1' in 21-35.
* Get total of 1s in 21-35 (with FS, letters will be treated as 0).
SORTOUT will have:
If there are numbers in the characters for which you want to count x's, change the ALTSEQ statement to:
Here is a DFSORT JCL which will give you the desired results. Using FINDREP we eliminate all character A thru Z and 0 thru 9 and ", - . By doing this we are only left with the character which you want to count. And now we convert this to VB file so that we get the accurate count of the characters. It also eliminates records without the | character
FINDREP function of DFSORT is available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008)