IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to find the number of records with a particular key


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Wed Mar 28, 2007 10:13 am
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: 1436
Location: Bangalore,India

PostPosted: Wed Mar 28, 2007 10:26 am
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 Developer


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

PostPosted: Wed Mar 28, 2007 8:34 pm
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
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: 1436
Location: Bangalore,India

PostPosted: Thu Mar 29, 2007 10:18 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top