View previous topic :: View next topic |
Author |
Message |
kanitha-mvs Beginner
Joined: 17 May 2006 Posts: 26 Topics: 17
|
Posted: Wed Jun 10, 2009 1:49 am Post subject: To extract count of duplicate records |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Jun 10, 2009 2:13 am Post subject: |
|
|
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 |
|
|
mickeygoo Beginner
Joined: 15 Nov 2007 Posts: 26 Topics: 7
|
Posted: Wed Jun 10, 2009 1:16 pm Post subject: |
|
|
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 |
|
|
mickeygoo Beginner
Joined: 15 Nov 2007 Posts: 26 Topics: 7
|
Posted: Wed Jun 10, 2009 1:19 pm Post subject: |
|
|
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 |
|
|
kanitha-mvs Beginner
Joined: 17 May 2006 Posts: 26 Topics: 17
|
Posted: Fri Jun 12, 2009 7:42 am Post subject: |
|
|
Thanks a lot kolusu & mickeygoo. it works.... |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Tue Jul 07, 2009 7:01 pm Post subject: |
|
|
Can someone explain what A1,N09 represents in the VALCNT parameter ? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
|
|