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
 

 

Get duplicates along with the count

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

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Dec 22, 2005 2:38 am    Post subject: Get duplicates along with the count
Reply with quote

I need to create one single file deviod of duplicates along with the count. Like :

Input File A :

Code:
         
aaaaa   
aaaaa
bbbbb
bbbbb
bbbbb
bbbbb
ccccc


Output file should be like :

Code:

aaaaa 2
bbbbb 4
ccccc 1


How can I use the sort utility for this?
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: Thu Dec 22, 2005 3:28 am    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
aaaaa
aaaaa
bbbbb
bbbbb
bbbbb
bbbbb
ccccc
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,5,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,5,
      TRAILER3=(1,5,X,COUNT=(M11,LENGTH=1)))
/*


If the records are already in sorted order as shown, then you could do a merge instead of a sort (change SORTIN to SORTIN01 and change SORT to MERGE).
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Dec 22, 2005 5:22 am    Post subject:
Reply with quote

Frank Yaeger wrote:
Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
aaaaa
aaaaa
bbbbb
bbbbb
bbbbb
bbbbb
ccccc
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,5,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,5,
      TRAILER3=(1,5,X,COUNT=(M11,LENGTH=1)))
/*


If the records are already in sorted order as shown, then you could do a merge instead of a sort (change SORTIN to SORTIN01 and change SORT to MERGE).



Thanks for that answer Frank.
But when I try to write this to a sortout file which has double the recordlength of the input file its abending with this info:
1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 18:41 ON WED DEC 21, 200
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,5,
TRAILER3=(1,5,X,COUNT=(M11,LENGTH=1)))
0 RECORD TYPE IS F - DATA STARTS IN POSITION 1
0 5 BYTE FIXED RECORD LENGTH IS NOT EQUAL TO 7 BYTE LRECL FOR SORTOUT
0 C5-K05352 C6-Q95214 C7-K90000 C8-K05352 E9-K06751 E7-K90000
3 END OF DFSORT

Here I have a input file of length 5. And I need to write the ouput to a file of record length 7.
Also what shud I do to write only those records whose count exceeds certain limit only. Like
Input File:
aaaa
bbbb
aaaa
aaaa
bbbb
ccccc

I need an output file with only those records whose count is equal to 3. So my output file shud be like
aaaa
Please help.

Thanks,
Nithin.
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: Thu Dec 22, 2005 6:13 am    Post subject:
Reply with quote

Nithin,

It would really help if you gave all the information needed for somebody to figure out what you want to do in your first post. You showed an example of your input records and what you wanted for output. I showed you how to do that. Now you're telling me you want this and this and ... It's very hard to hit a moving target. In the future, please try to give all of the information needed in your first post.

If your input file has LRECL=5 and you want the output file to have LRECL=7, change the OUTFIL statement to:

Code:

  OUTFIL REMOVECC,NODETAIL,                 
    OUTREC=(1,5,2X),                         
    SECTIONS=(1,5,                           
      TRAILER3=(1,5,X,COUNT=(M11,LENGTH=1)))


If you want to write records with a count equal to 3 (without having the actual count in the records), you can use a DFSORT/ICETOOL job like this:

Code:

//S2   EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN DD DSN=...  input file                               
//T1   DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)   
//OUT  DD DSN=...  output file                                           
//TOOLIN   DD *                                               
SELECT FROM(IN) TO(T1) ON(1,5,CH) EQUAL(3)                     
SELECT FROM(T1) TO(OUT) ON(1,5,CH) FIRST                       
/*
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Thu Dec 22, 2005 9:39 pm    Post subject: Multiple input files single output file
Reply with quote

Frank,
Thanks for all your help. My problem got resolved by using the second method you provided me. Again, now I am stuck with a different problem.
Here I have multiple input files having the same format and I need a single output file having the same format as that of input file having only those records present all the different input file.
Like :

Input1:
AAA
AAA
BBB
CCC
DDD

Input2:
AAA
AAA
BBB
CCC

Input3:
CCC

My outptu file shud be like
Output file:
AAA
CCC

Please help me.
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: Thu Dec 22, 2005 10:59 pm    Post subject:
Reply with quote

In the future, please start a new topic for a new question - it makes it easier to search.


You say
Quote:
having only those records present all the different input file.


Your output has AAA and CCC, but Input3 only has CCC. AAA is not present in all the input files so why would you expect it to be in the output file?. Please clarify.
Back to top
View user's profile Send private message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Fri Dec 23, 2005 1:22 am    Post subject: multiple input single output
Reply with quote

Sorry, that was a mistake i made while sending the query. It shud be like
Input1:
AAA
AAA
BBB
CCC
DDD

Input2:
AAA
AAA
BBB
CCC

Input3:
AAA
CCC

My outptu file shud be like
Output file:
AAA
CCC

So basically I need those records common all the input files with no dups.
Frank Yaeger wrote:
In the future, please start a new topic for a new question - it makes it easier to search.


You say
Quote:
having only those records present all the different input file.


Your output has AAA and CCC, but Input3 only has CCC. AAA is not present in all the input files so why would you expect it to be in the output file?. Please clarify.
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: Fri Dec 23, 2005 2:03 am    Post subject:
Reply with quote

See my response in the new topic.
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 Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am


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