View previous topic :: View next topic
|
Author |
Message |
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi,
I need a sort card to eliminate duplicates in different scenario.
Assuming input file holds below values
Input:
AAA
AAA
BBB
CCC
CCC
Output:
BBB
The output file must hold only the unique value BBB alone.
Is there any option to achive this in Sort card? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Do you need to sort the data, or is it already sorted?
Are you able to use SyncTool (often "aliased" as ICETOOL). If so, you can look at the SELECT operator. |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
Data will be sorted in previous step, Actually the data will be present in two input files. so data will be concatinated and sorted to bring it to single file.
It would be fine if option present in ICETOOL and will it be possible to sort in the same step of the above query. Thanks |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, SELECT with NODUPS should do you, with USING(xxxx) and an xxxxCNTL with OPTION COPY.
If there is an earlier step simply to sort the file for this process, that can be included in the same step, with the removal of the USING (by default, the data will be sorted on the ON values). |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
Oh Great! Can I have a sample syntax to achive this. Thanks... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Also, if your SyncSort is current, look at this to see what to look at in your manual for another way to do it conveniently. |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
I think the provided information would be sufficient for me.
Great! Thanks for help bill. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No problem. Thanks for letting us know.
It is lucky, as I completely missed that you wanted more, as our messages "crossed in the post" as it were. |
|
Back to top |
|
|
sandip_mainframe Warnings : 2 New User
Joined: 20 Sep 2006 Posts: 63 Location: pune
|
|
|
|
Hi Senthil,
You can use below code -
Code: |
//STEP2 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN01 DD *
AAA
BBB
AAA
CCC
CCC
//OUT01 DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN01) TO(OUT01) ON(01,03,CH) NODUPS
//* |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Sandip,
The data is already sorted. As you have coded that, it will be sorted again, which is a waste of resources. You need USING(xxxxCNTL) and have OPTION COPY in the xxxxCNTL DD. |
|
Back to top |
|
|
sandip_mainframe Warnings : 2 New User
Joined: 20 Sep 2006 Posts: 63 Location: pune
|
|
|
|
Oops my Bad. Thanks Bill for pointing out my mistake. |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
As per your suggestion, I tried and got my data sorted as expected. I have specified the syntax below since it might be useful for people referring.
//TOOLIN DD *
SELECT FROM(INPUT) TO(DUP) DISCARD(NODUP) -
ON(1,7,CH) ALLDUPS USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,7,CH,A)
Thanks again for lightning speed response. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
To confirm that you've now "merged" two tasks, which is the original sorting of the file and the de-duplication.
If you don't need the discarded data for anything, you can remove the DISCARD and its DD.
If you are doing the SORT in this step as well, you don't need to specify it in the CTL1CNTL, as it will be automatic for SELECT. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Will either of the 2 input files contain duplicates or are duplicates introduced when the 2 sets of data are combined?
If the 2 inpt files are only unique entries, you might consider JOINKEYS. |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
Previously I had a sort step to merge the 2 files in sorted order to bring it to one file and eliminate the duplicate records. Now I have removed the previous sort step and achieved it in one step. Thanks
Also thanks for updating me that SELECT will do SORTING by default.
Hi Dick scherrer, Thanks for the invite. Eiter of the 2 files cannot have duplicates. only on merging they can have. So i have included sort in control cards. Thanks |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
To add, I need both DUP & NODUP records. So I kept DISCARD as it is. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Then i'd suggest you look at JOINKEYS - not only for this process, but others in the future. I believe there is more flexibility with a JOINKEYS |
|
Back to top |
|
|
|