View previous topic :: View next topic
|
Author |
Message |
danylele74
New User
Joined: 03 Jul 2014 Posts: 27 Location: Italy
|
|
|
|
Hello,
I have to solve a problem.
I have a file where, for the same key, I removed duplicate records writing in a second file.
After processing the first file (without keys doubles) I need to insert a value in the second file with the same key.
example:
file 1
Code: |
Key Value
001
001
001
002
002
003 |
Removing duplicate keys
file 1
Code: |
Key Value
001
002
003 |
file 2
Code: |
Key Value
001
001
002 |
File 1 after processing
Code: |
Key Value
001 555
002 666
003 777 |
Output file
Code: |
Key Value
001 555
001 555
001 555
002 666
002 666
003 777 |
I need you help.
Thank you. |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7311 Location: Inside the Matrix
|
|
|
|
Your final output just looks like your original file with some extra stuff (source unknown) added to it. |
|
Back to top |
|
 |
danylele74
New User
Joined: 03 Jul 2014 Posts: 27 Location: Italy
|
|
|
|
yes. It's the same file but with the "value" field filled after processing |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7311 Location: Inside the Matrix
|
|
|
|
OK, but where do the new values come from and how are they applied? You want to do this with your SORT product? Which one do you have? |
|
Back to top |
|
 |
danylele74
New User
Joined: 03 Jul 2014 Posts: 27 Location: Italy
|
|
|
|
The "original" file is
Code: |
Key Fied-X
001
001
001
002
002
003
|
The original file without duplicate key (called NODUP)
Code: |
Key Fied-X
001
002
003
|
The original file with ONLY duplicate key (called DUP)
Code: |
Key Fied-X
001
001
002
|
File NODUP after processing (processed by a program)
Code: |
Key Fied-X
001 555
002 666
003 777
|
The output file (NODUP + DUP)
Code: |
Key Fied-X
001 555
001 555
001 555
002 666
002 666
003 777
|
|
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7311 Location: Inside the Matrix
|
|
|
|
OK, it would seem to me that the program which puts the new value one should have no real problem with processing the original file: keep a note of key change; if so, add the value, also save it; if not key change, add the saved value.
For what you have ended up with, use MERGE with OPTION EQUALS and IFTHEN=(WHEN=GROUP with KEYBEGIN to PUSH the value from the first record to all records in the group. |
|
Back to top |
|
 |
|