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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm


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