MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Identify and replace trailing variables.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 46
Topics: 14

PostPosted: Fri Dec 14, 2018 10:25 am    Post subject: Identify and replace trailing variables. Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Dec 14, 2018 11:08 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 46
Topics: 14

PostPosted: Fri Dec 14, 2018 2:04 pm    Post subject: Reply with quote

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


Joined: 18 Apr 2016
Posts: 46
Topics: 14

PostPosted: Fri Dec 14, 2018 2:13 pm    Post subject: Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Dec 14, 2018 3:52 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
ramy2016
Beginner


Joined: 18 Apr 2016
Posts: 46
Topics: 14

PostPosted: Thu Dec 27, 2018 11:42 am    Post subject: Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Dec 27, 2018 12:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group