- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, researchers.
I would like to substring a person's name from a description.
It seems to have a rule like XXX will become, XXX will step.
Therefore, how do I substring person's name before will?
data have;
input x $50.;
cards;
A Barr Dolan will become
A Brooke Seawell will step
Aharon Schwartz will become
Maureen F Morrison will become
Matthew Bilunas will become
;
run;
Output Want
Text Name
A Barr Dolan will become A Barr Dolan
A Brooke Seawell will step A Brooke Seawell
Aharon Schwartz will become Aharon Schwartz
Thanks in advance.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
where=findw(x,'will',' ');
name=substr(x,1,where-2);
run;
This method fails for someone who has the name "will" in their name, such as the famous political writer George F. Will or the famous actor Will Smith, unless we can depend on the fact that all names are properly capitalized in the data set. It also fails if will is capitalized as "Will", or if will does not exist in the string.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
where=findw(x,'will',' ');
name=substr(x,1,where-2);
run;
This method fails for someone who has the name "will" in their name, such as the famous political writer George F. Will or the famous actor Will Smith, unless we can depend on the fact that all names are properly capitalized in the data set. It also fails if will is capitalized as "Will", or if will does not exist in the string.
Paige Miller