View previous topic :: View next topic
|
Author |
Message |
Ganesh Kalam Warnings : 1 New User
Joined: 11 Aug 2005 Posts: 45 Location: India
|
|
|
|
Hi,
My Input file is like this
100 A
100 B
100 C
200 A
200 C
300 E
400 F
400 G
Consider the first three characters as key.. My output should look like
100 3
200 2
300 1
400 2
My requirement is, i should write the key along with the number of occurences of key in the input file.
Please help me in doing this operation. Thanks in advance .. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi There,
You can use following sort card for this
Code: |
//SYSIN DD *
INREC FIELDS=(1,80,C'1')
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(81,1,ZD)
OUTREC FIELDS=(1,3,4,1,81,1,80:X)
/ |
* |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Hi Ganesh,
In addition to Ekta's solution, you could use the following for your requirement -
Code: |
//SPLIT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//*
//SORTIN DD *
100 A
100 B
100 C
200 A
200 C
300 E
400 F
400 G
/*
//*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
SORT FIELDS=COPY
*
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,3,
TRAILER3=(1,3,10:COUNT=(M10,LENGTH=5)))
/*
|
[/code] |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can also use this DFSORT/ICETOOL job:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//RPT DD SYSOUT=*
//TOOLIN DD *
OCCUR FROM(IN) LIST(RPT) ON(1,3,CH) ON(VALCNT) BLANK
/*
|
RPT will have:
Code: |
(1,3,CH) VALUE COUNT
100 3
200 2
300 1
400 2
|
You can use various ICETOOL formatting options to change the way the report looks. |
|
Back to top |
|
|
Ganesh Kalam Warnings : 1 New User
Joined: 11 Aug 2005 Posts: 45 Location: India
|
|
|
|
Hi Ekta/Murali/Frank,
I tried the solutions given by Murali and Frank. They are working fine and meets my requirement.
Ekta, I am getting an error while trying your sort card. It seems there is a problem with outrec statement. I could not figure out the exact error. Can you please check it.
Thanks again for your quick response. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Ganesh,
Could it be possible to post the spool messages so that we can help you out? |
|
Back to top |
|
|
|