View previous topic :: View next topic |
Author |
Message |
ramy2016 Beginner
Joined: 18 Apr 2016 Posts: 46 Topics: 14
|
Posted: Fri Dec 14, 2018 10:25 am Post subject: Identify and replace trailing variables. |
|
|
Good day everyone,
please let me know if this can be accomplished using DFSort.
Have records where a name field can have names mixed with some other trailing values, which could be numeric or alphanumeric.
There is at least one space between a name and other value, as well as possible trailing spaces.
There are no leading spaces.
The dataset is FB, LRECL=185, and the name field is at 37:25.
Code: | NAME-FIELD
----------------------------------
MCKAY 9031701157
BROOKS
TAYLOR 990-30-45822
MARTINEZ 14A4206
SATCO 77218-000019
LAKPA 1006770441
RIVIERA |
My goal is to clean up the name field by replacing after-the-name values with spaces.
Thanks. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri Dec 14, 2018 11:08 am Post subject: |
|
|
ramy2016,
How would you handle names with embedded spaces?
Code: |
Ramy lastname 2016
Fname Mname Lname 2018
|
Should we only remove the last variable or should we remove everything after we encounter the first space? _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
ramy2016 Beginner
Joined: 18 Apr 2016 Posts: 46 Topics: 14
|
Posted: Fri Dec 14, 2018 2:04 pm Post subject: |
|
|
I was thinking of something like:
1. start validating from the end of a name field, going towards the beginning
2. check for strings ending with at least 2 or 3 numerics
3. go from there until the first space encountered |
|
Back to top |
|
|
ramy2016 Beginner
Joined: 18 Apr 2016 Posts: 46 Topics: 14
|
Posted: Fri Dec 14, 2018 2:13 pm Post subject: |
|
|
So, yes - remove the last variable (if there) which would always end with few numerics.
This is what your example should look like.
Code: |
Ramy lastname
Fname Mname Lname |
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri Dec 14, 2018 3:52 pm Post subject: |
|
|
ramy2016,
I think of couple of ways to get this done, but data like this would throw in a monkey wrench
Code: |
----+----1----+----2----+----3
A B C D E F G H I J K L M
|
In this case you don't want to drop the M as it does not have numeric. Also Suffixes can be another issue
Code: |
ROBERT WILLIAM SR
ROBERT WILLIAM JR
ROBERT MONDAVI III
ROBERT MONDAVI IV
..
|
So probably a cobol program with INSPECT reverse to find the last space and then validate if it has a numeric and then replace the value with spaces. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
ramy2016 Beginner
Joined: 18 Apr 2016 Posts: 46 Topics: 14
|
Posted: Thu Dec 27, 2018 11:42 am Post subject: |
|
|
Sorry kolusu for a late response, didn't mean to be rude, just been busy at work and then holidays, vacations, etc.
I'm still wondering if this can be achieved in DFSORT, if I simplify Input.
Let's say a name field value would consist of either a Last name only, and a Last name and a one trailing value, like I presented in my first post.
Code: |
NAME-FIELD
----------------------------------
MCKAY 9031701157
BROOKS
TAYLOR 990-30-45822
MARTINEZ 14A4206
SATCO 77218-000019
LAKPA 1006770441
RIVIERA
|
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu Dec 27, 2018 12:18 pm Post subject: |
|
|
ramy2016 wrote: | Sorry kolusu for a late response, didn't mean to be rude, just been busy at work and then holidays, vacations, etc.
I'm still wondering if this can be achieved in DFSORT, if I simplify Input.
Let's say a name field value would consist of either a Last name only, and a Last name and a one trailing value, like I presented in my first post. |
Ramy2016,
You need to devise solutions that would account for all kinds of data rather than assuming the data be just one variation.
Anyway since you are fixated on a sort solution, here is a simple way to get rid off any thing after a space.
Code: |
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=185,IFTHEN=(WHEN=INIT,
OVERLAY=(186:37,25)),
IFTHEN=(WHEN=INIT,
PARSE=(%01=(ABSPOS=186,ENDAT=C' ',FIXLEN=25)),
OVERLAY=(037:%01))
/* |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|