|
View previous topic :: View next topic
|
| Author |
Message |
meetsrk
New User

Joined: 13 Jun 2004 Posts: 85
|
|
|
|
I need a help in counting,
Input file is of 4096 length but i need counts based on 3 variables,
X => Size 8
Y => Size 12
Z => Size 1
| Code: |
Data in that file will be like,
x y z
aaaaaa 111111 @ ....
aaaaaa 111111 @ ...
aaaaaa 111111 @ ....
aaaaaa 111111 $ ....
aaaaaa 111111 * ...
aaaaaa 222222 @ ...
aaaaaa 222222 % ...
aaaaaa 222222 $ ....
bbbbbb 111111 % ....
bbbbbb 111111 % ...
........................................
........................................
O/p should have counts like below,
aaaaaa 111111 @ = 3
aaaaaa 111111 $ = 1
aaaaaa 111111 * = 1
aaaaaa 222222 @ = 1
aaaaaa 222222 % = 1
aaaaaa 222222 $ = 1
bbbbbb 111111 % = 2
|
|
|
| Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
It should be easy for you, you have the right sort.....
Basicly sort on the field you want to count and, after defining an additional input field of 001, sum on that field. |
|
| Back to top |
|
 |
meetsrk
New User

Joined: 13 Jun 2004 Posts: 85
|
|
|
|
Hi William,
Can you put some code over here for better understanding? |
|
| Back to top |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I couldn't, but you could...If you know Icetool, you must be using DFsort, and therefore have the manual, and therefore can do it.
Baring that, look back for previous posts, Frank has been making sort jump through hoops and all has been revealed...... |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Meetsrk,
You can use a DFSORT job like the following to do what you want.
| Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/4096)
//SORTOUT DD DSN=... output file (FB/25)
//SYSIN DD *
SORT FIELDS=(1,21,BI,A)
OUTFIL REMOVECC,NODETAIL,
OUTREC=(1,21,25:X),
SECTIONS=(1,21,
TRAILER3=(1,21,X,'=',X,COUNT=(M11,LENGTH=1)))
/*
|
SORTOUT will have the following:
| Code: |
aaaaaa 111111 $ = 1
aaaaaa 111111 * = 1
aaaaaa 111111 @ = 3
aaaaaa 222222 $ = 1
aaaaaa 222222 % = 1
aaaaaa 222222 @ = 1
bbbbbb 111111 % = 2
|
Note that the records are in the correct sorted order (e.g. $, *, %, @). The output you show is not sorted correctly. If you want the output in some nonstandard sorted order, tell me what order you want the $, *, % and @ characters in and I'll show you how to change the job. |
|
| Back to top |
|
 |
meetsrk
New User

Joined: 13 Jun 2004 Posts: 85
|
|
|
|
Frank,
Can you pls explain the code on how it works?
| Code: |
SORT FIELDS=(1,21,BI,A)
OUTFIL REMOVECC,NODETAIL,
OUTREC=(1,21,25:X),
SECTIONS=(1,21,
TRAILER3=(1,21,X,'=',X,COUNT=(M11,LENGTH=1)))
|
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Meetsrk,
We sort on positions 1-21 to get the records in order.
We use REMOVECC to suppress ANSI carriage control characters.
We use NODETAIL to suppress the detail records (we only want the TRAILER3 records).
We use OUTREC to get positions 1-21 followed by 4 blanks to pad the records out to the 25 bytes we need for the trailer records.
We use SECTIONS, TRAILER3 and COUNT to display positions 1-21 and the count each time the value in positions 1-21 changes.
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
Use [URL] BBCode for External Links |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|