IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

remove dublicates and keep last record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Wed Apr 06, 2011 6:04 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Apr 06, 2011 6:30 pm
Reply with quote

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
View user's profile Send private message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Wed Apr 06, 2011 6:54 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Apr 06, 2011 7:43 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 06, 2011 9:10 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top