View previous topic :: View next topic
|
Author |
Message |
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
Hello
Can you please tell me how can I remove duplicate records from a FB data set of length and keep the last record in output file instead of keeping the first record
Ex
AAAAAAAAAA04012007
AAAAAAAAAA04012008
AAAAAAAAAA04012009
AAAAAAAAAA04012010
BBBBBBBBBB04012007
BBBBBBBBBB04012008
BBBBBBBBBB04012009
BBBBBBBBBB04012010
First 10 bytes is key and next 8 bytes is date value, I need to sort this file for unique key values and keep last record of that particular key in output file, which mean my output should be
AAAAAAAAAA04012010
BBBBBBBBBB04012010
Can this achieved with sort? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
OK...
Tell us what output you are expected if your input file is like
Code: |
AAAAAAAAAA04012007
AAAAAAAAAA04012008
AAAAAAAAAA04012010
AAAAAAAAAA04012009
BBBBBBBBBB04012007
BBBBBBBBBB04012008
BBBBBBBBBB04012009
BBBBBBBBBB04012010
|
should it be
Code: |
AAAAAAAAAA04012010
BBBBBBBBBB04012010 |
or
Code: |
AAAAAAAAAA04012009
BBBBBBBBBB04012010 |
|
|
Back to top |
|
|
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
Sambhaji
Thanks for the response, Records won't be like that, highest year record will the last record for particular key. So that scenario will not come.
Thanks |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Try,
Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD *
AAAAAAAAAA04012007
AAAAAAAAAA04012008
AAAAAAAAAA04012009
AAAAAAAAAA04012010
BBBBBBBBBB04012007
BBBBBBBBBB04012008
BBBBBBBBBB04012009
BBBBBBBBBB04012010
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,10,CH) LAST |
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Hima1985,
If the input data is already sorted on the key and date then you can use a COPY operation instead of sort like shown below.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAAAAAAA04012007
AAAAAAAAAA04012008
AAAAAAAAAA04012009
AAAAAAAAAA04012010
BBBBBBBBBB04012007
BBBBBBBBBB04012008
BBBBBBBBBB04012009
BBBBBBBBBB04012010
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,10,TRAILER3=(1,80))
//* |
|
|
Back to top |
|
|
|