Page 1 of 1

Merge 2 files with key at different position.

PostPosted: Fri May 27, 2016 8:59 pm
by pawantm
Hi,

I need to merge 2 files into one. Below is the example:

File1:

ABC 123 DEF
ABC 456 DEF
ABC 789 DEF


File2:

ABC DEF 123
ABC DEF 456
ABC DEF 789


OUTPUT File :

ABC 123 DEF
ABC DEF 123
ABC 456 DEF
ABC DEF 456
ABC 789 DEF
ABC DEF 789

Numbers in both the files are key at different position. Key at file 1 start from position 4 and key in file 2 starts from position 9. I have to create a output as illustrated above i.e. file1 record and then file2 record based on keys. Both the files have same no. of records and same keys.

Re: Merge 2 files with key at different position.

PostPosted: Sat May 28, 2016 12:39 am
by BillyBoyo
If the two files are in the correct order, a simple MERGE with an INREC to use OVERLAY to extend each record to format the "key" for the MERGE from different locations on the records. If you can uniquely identify from NUMeric, then you can do that.

If you only know from which dataset it is on, then do the same type of thing in the JNFnCNTL files of a JOINKEYS. Here you'd have to handle output processing of any duplicate keys yourself.