View previous topic :: View next topic
|
Author |
Message |
ramankapoor
New User
Joined: 27 Feb 2006 Posts: 23 Location: delhi
|
|
|
|
Hye.. please give me the the control card option to eliminates Duplicates and retain the first record.
To Eliminates Duplicates we have to do Sum=None
but to retain the first record what should i have to use . pls suggest..
To Eliminates Duplicates and retain the first record |
|
Back to top |
|
|
fixdoubts
New User
Joined: 21 Oct 2005 Posts: 54
|
|
|
|
Hi,
Try this out..
Code: |
//STEP0100 EXEC PGM=SORT
//SORTIN DD *
1111 AAAA 2222
1111 AAAA 3333
1111 AAAA 2222
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,14,CH,A)
SUM FIELDS=NONE
/*
|
The out put will be
Code: |
1111 AAAA 2222
1111 AAAA 3333 |
Change the key as per your requirements
Regards, |
|
Back to top |
|
|
ramankapoor
New User
Joined: 27 Feb 2006 Posts: 23 Location: delhi
|
|
|
|
But the solution u have given ,
in the output its showing two records while i like to retain just first record. |
|
Back to top |
|
|
fixdoubts
New User
Joined: 21 Oct 2005 Posts: 54
|
|
|
|
Hi,
There are only two distinct records
1111 AAAA 2222
1111 AAAA 3333
and the third record
1111 AAAA 2222
is a duplicate.
I think this is what u wanted. Keep only one record and eliminate dulicate |
|
Back to top |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
The other alternative solution is to use Select clause with first dup option.
SELECT FROM(INDD) TO(OUTDD) ON(P,M,F) FIRSTDUP
Thanks
Krishy |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
please give me the the control card option to eliminates Duplicates and retain the first record. |
There are two ways to do this with DFSORT as shown below:
Method 1 - DFSORT/ICETOOL SELECT FIRST
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(p,m,f) FIRST
|
p,m,f is the starting position, length and format of the key. You can use multiple ON fields if you have multiple keys.
Method 2 - DFSORT SUM with EQUALS
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(p,m,f,A)
SUM FIELDS=NONE
/*
|
EQUALS ensures that the first record of duplicates is kept (note that SELECT uses EQUALS automatically). p,m,f is the starting position, length and format of the key. You can use multiple keys if appropriate.
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
Use [URL] BBCode for External Links |
|
Back to top |
|
|
|