View previous topic :: View next topic
|
Author |
Message |
TGarcia
New User
Joined: 24 Jul 2021 Posts: 3 Location: United States
|
|
|
|
How can I read two DSN compared one variable:
Code: |
FILE1:
ALBERT DAILY
MARK WEEKLY
PETER MONTHLY
|
Code: |
FILE2:
ALBERT 651-222-4561
ALBERT 651-333-4562
PETER 651-444-1235 |
Code: |
DESIRED OUTPUT:
ALBERT DAILY 651-222-4561
ALBERT DAILY 651-333-4562
PETER MONTHLY 651-444-1235 |
Coded |
|
Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 2992 Location: NYC,USA
|
|
|
|
Why REXX? Easier and faster with DFSORT/SYNCSORT.
Please use code tags. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 1751
|
|
|
|
Quote: |
How can I read two DSN compared one variable: |
Please, clarify this using the commonly used terminology. |
|
Back to top |
|
 |
Pedro
Global Moderator

Joined: 01 Sep 2006 Posts: 2408 Location: Silicon Valley
|
|
|
|
Judging from the example, he wants to use the name column to join two tables.
The data is not in DB2 tables, so the join needs to be done through a program. |
|
Back to top |
|
 |
Willy Jensen
Active Member

Joined: 01 Sep 2015 Posts: 658 Location: Denmark
|
|
|
|
You use the fact that a stem suffix is just a string. I assume that dataset 1 is the master, which will contain all names found in dataset 2.
Then this will do it:
Code: |
/* populate lists */
list1.1='ALBERT DAILY '
list1.2='MARK WEEKLY '
list1.3='PETER MONTHLY '
list1.0=3
list2.1='ALBERT 651-222-4561 '
list2.2='ALBERT 651-333-4562 '
list2.3='PETER 651-444-1235'
list2.0=3
/* split list1, make master */
mstr.='?'
do n=1 to list1.0
parse var list1.n name text
mstr.name=text
end
/* make result list (replace list2) */
do n=1 to list2.0
parse var list2.n name text
list2.n=name mstr.name subword(list2.n,2)
end
/* show */
do n=1 to list2.0
say list2.n
end |
|
|
Back to top |
|
 |
|