MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

To extract count of duplicate records

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
kanitha-mvs
Beginner


Joined: 17 May 2006
Posts: 26
Topics: 17

PostPosted: Wed Jun 10, 2009 1:49 am    Post subject: To extract count of duplicate records Reply with quote

Hi,

I have a input file with the following data.

LRECL = 16(1-7 some data, 8 -filler, 9-16 - date)
AAAAAA 06/04/2009
AAAAAA 06/04/2009
BBBBBB 06/04/2009
BBBBBB 06/05/2009
BBBBBB 06/06/2009
I need to count the number of records present for each date in the file.
Currently am using a sort utility to compare the position 9-16 against hardcoded date value(30 condition checks). Is it possible to get the count by some other easiest way?
Please advise.
Thanks,
kanitha-mvs.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Jun 10, 2009 2:13 am    Post subject: Reply with quote

Kanitha-mvs,

Something doesn't match up. You say your date field is only 8 bytes (pos 9 thru 16 but you show 10 bytes date. Assuming your date field is only 8 bytes you can very easily count the records based on the date using sections and trailer3. I assumed that your date field is of the format mmddyyyy format. Here is an untested code

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
----+----1----+-
AAAAAAA 06042009
AAAAAAA 06042009
BBBBBBB 06042009
BBBBBBB 06052009
BBBBBBB 06062009
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=(13,4,CH,A,9,4,CH,A)
  OUTFIL REMOVECC,NODETAIL,BUILD=(17X),
  SECTIONS=(9,8,TRAILER3=(9,8,X,COUNT))
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Wed Jun 10, 2009 1:16 pm    Post subject: Reply with quote

something like this, perhaps?


Code:


//JS010    EXEC PGM=ICETOOL             
//INPUT    DD *                         
----+----1----+----2----+----3----+----4
AAAAA 06/04/2009                       
AAAAA 06/04/2009                       
BBBBB 06/04/2009                       
BBBBB 06/05/2009                       
BBBBB 06/06/2009                       
/*                                     
//*                                     
//OUTPUT   DD SYSOUT=*                 
//TOOLMSG  DD SYSOUT=*                 
//DFSMSG   DD SYSOUT=*                 
//*                                     
//TOOLIN   DD *                         
  OCCUR FROM(INPUT) LIST(OUTPUT) -     
    HEADER('DATE') ON(7,10,CH) -       
    HEADER('COUNT') ON(VALCNT,A1,N09)   
/*                                     
//*                                     



Output would be:

Code:


********************************* TOP OF DATA **********************************
DATE                COUNT                                                       
----------   ------------                                                       
06/04/2009              3                                                       
06/05/2009              1                                                       
06/06/2009              1                                                       
******************************** BOTTOM OF DATA ********************************

Back to top
View user's profile Send private message
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Wed Jun 10, 2009 1:19 pm    Post subject: Reply with quote

Add another header line if you want to count unique values in the first column as well...

Code:

  OCCUR FROM(INPUT) LIST(OUTPUT) -     
    HEADER('DATE') ON(7,10,CH) -       
    HEADER('FIRST COLUMN') ON(1,5,CH) -
    HEADER('COUNT') ON(VALCNT,A1,N09) 


to get this:

Code:

********************************* TOP OF DATA **********************************
DATE         FIRST COLUMN          COUNT                                       
----------   ------------   ------------                                       
06/04/2009   AAAAA                     2                                       
06/04/2009   BBBBB                     1                                       
06/05/2009   BBBBB                     1                                       
06/06/2009   BBBBB                     1                                       
******************************** BOTTOM OF DATA ********************************


HTH
Back to top
View user's profile Send private message
kanitha-mvs
Beginner


Joined: 17 May 2006
Posts: 26
Topics: 17

PostPosted: Fri Jun 12, 2009 7:42 am    Post subject: Reply with quote

Thanks a lot kolusu & mickeygoo. it works....
Back to top
View user's profile Send private message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Jul 07, 2009 7:01 pm    Post subject: Reply with quote

Can someone explain what A1,N09 represents in the VALCNT parameter ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jul 07, 2009 7:56 pm    Post subject: Reply with quote

tcurrier,

Read here about Edit Mask Patterns for A

Read here about Ndd or Udd Formatting
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group