Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Counting Number of records for Each Unique Key

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

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Tue Jul 28, 2009 11:32 am    Post subject: Counting Number of records for Each Unique Key
Reply with quote

Hi all,

I have Input dataset as shown below,

Code:


A 10
B 20
C 30
D 40
B 40
C 20
A 10
C 25



I would like to display my output report like this,

Code:


TOTAL COUNT FOR A : 20
TOTAL COUNT FOR B : 60
TOTAL COUNT FOR C : 75
TOTAL COUNT FOR D : 40



Can anyone suggest me a solution for this?
Back to top
View user's profile Send private message

Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Tue Jul 28, 2009 11:34 am    Post subject:
Reply with quote

HI all,

LRECL = 80, RECFM = FB

First column starts in Position 1.
Second column starts in Position 3.
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Tue Jul 28, 2009 12:29 pm    Post subject: Reply to: Counting Number of records for Each Unique Key
Reply with quote

Try using the below code:

Code:
//SYSIN DD *
 OPTION ZDPRINT
 SORT FIELDS=(1,1,CH,A)
 SUM FIELDS=(3,2,ZD)
/*



Thanks,
-Kapil.
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Tue Jul 28, 2009 12:35 pm    Post subject: Reply to: Counting Number of records for Each Unique Key
Reply with quote

use outrec to get the result in desired format.

Code:

  OUTREC FIELDS=(C'TOTAL COUNT FOR ',1,1,X,C':',X,3,2,80:X)
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Tue Jul 28, 2009 5:54 pm    Post subject:
Reply with quote

Hi,

Im getting S0C7 abend for my below input,

Code:

                 HEADER1
                 HEADER2
                 HEADER3
                 
A   100
B    30
C     3

A   217
B     3
C   100

A 1,234
B     9
C    24



I have never encountered S0C7 abend in DFSORT step.
After making 1,234 as 1234 and removing the header lines the code is working fine.

Can anyone explain why im getting S0C7 abend?and also solution to counter this.

This is my sort step,
Code:


  OPTION ZDPRINT,SKIPREC=3                                           
  INCLUDE COND=(53,7,CH,NE,C'       ')                               
  SORT FIELDS=(53,47,CH,A)                                           
  SUM FIELDS=(124,8,ZD)                                             
  OUTREC FIELDS=(C'TOTAL EXCEPTIONS FOR ',53,47,X,C':',X,124,8,160:X)


My input LRECL = 160 and RECFM=FB
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: Tue Jul 28, 2009 9:14 pm    Post subject:
Reply with quote

You're getting a S0C7 because 1,234 is not a valid ZD value. You could fix the suggested control statements by adding:

Code:

  INREC OVERLAY=(124:124,8,UFF,TO=ZD,LENGTH=8) 


Alternatively, you could use these DFSORT control statements:

Code:

  OPTION ZDPRINT,SKIPREC=3                               
  INCLUDE COND=(53,7,CH,NE,C'       ')                   
  SORT FIELDS=(53,47,CH,A)                               
  OUTFIL REMOVECC,NODETAIL,                             
    SECTIONS=(53,47,                                     
     TRAILER3=(C'TOTAL EXCEPTIONS FOR ',53,47,' : ',     
       TOT=(124,8,UFF,M10,LENGTH=8)))                   
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Thu Jul 30, 2009 4:45 pm    Post subject: Reply to: Counting Number of records for Each Unique Key
Reply with quote

Hi all,

Thanks for Posting. Could you please suggest me how to include << END OF REPORT >> at the end of my output.

This is the sort step im using,

Code:


OPTION ZDPRINT,SKIPREC=5                                   
  INCLUDE COND=(53,7,CH,NE,C'       ')                     
  SORT FIELDS=(53,47,CH,A)                                 
  OUTFIL REMOVECC,NODETAIL,                               
    SECTIONS=(53,47,                                       
     TRAILER3=(C'TOTAL EXCEPTIONS FOR ',53,47,' : ',       
       TOT=(124,8,UFF,M10,LENGTH=8)))                     

Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jul 30, 2009 9:10 pm    Post subject:
Reply with quote

Vigneshwaran S,

Just add the trailer1 parm at the end

Use the following control cards

Code:

//SYSIN DD *                                           
  OPTION ZDPRINT,SKIPREC=5                             
  INCLUDE COND=(53,7,CH,NE,C' ')                       
  SORT FIELDS=(53,47,CH,A)                             
  OUTFIL REMOVECC,NODETAIL,                           
  SECTIONS=(53,47,                                     
  TRAILER3=(C'TOTAL EXCEPTIONS FOR ',53,47,' : ',     
            TOT=(124,8,UFF,M10,LENGTH=8))),           
  TRAILER1=(C'<< END OF REPORT >>')
//*
Back to top
View user's profile Send private message
Vigneshwaran S
Warnings : 1

New User


Joined: 10 Dec 2008
Posts: 60
Location: Chennai

PostPosted: Fri Jul 31, 2009 11:28 am    Post subject:
Reply with quote

Hi,

Thanks!!! I was trying with Trailer1 parm but i forgot to include comma at the end of Trailer3
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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts Profile changed to NUMBER ON STD (fro... Martylin TSO/ISPF 1 Thu Aug 03, 2017 9:14 am
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us