Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to find the number of records with a particular key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Wed Mar 28, 2007 9:40 am    Post subject: How to find the number of records with a particular key
Reply with quote

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
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Mar 28, 2007 10:13 am    Post subject:
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Mar 28, 2007 10:26 am    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Mar 28, 2007 8:34 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Thu Mar 29, 2007 10:15 am    Post subject:
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Thu Mar 29, 2007 10:18 am    Post subject:
Reply with quote

Ganesh,

Could it be possible to post the spool messages so that we can help you out?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us