BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sufiya
Quartz | Level 8

Hi, I have a column from which I need to extract text after a specific index word (MP).using the following code: 

catx(" ", scan(TEST_NAME , 2, "MP")) as NAME,

this is what I end up with:

TEST_NAMENAME
MP KONSTANTINE ABCDE 
WNP BM OPS TEST MP CIGI FANNINGBM O
MP DAN BkENTHER 
ERA MONTREAL TEST MP MARIA PUBRANTIMARIA PUBRANTI
MP MARIA PUBRANTI 
MP BRUCE WAYNE 
MYABCD DIG CHAN TEST MP ABCDE DADOUNABCDE DADOUN
MP JENNIFER NOSNIKOFOSNIKOF
MP STEVE PETERSE PETERS

 

below is what I want - However, I can't seem to get the code right to extract the text after "MP", any suggestions, please? Kind regards 🙂

NAME
KONSTANTINE ABCDE
CIGI FANNING
DAN BkENTHER
MARIA PUBRANTI
MARIA PUBRANTI
BRUCE WAYNE
ABCDE DADOUN
MP JENNIFER NOSNIKOF
STEVE PETERS

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You can use FINDW and SUBSTR

 

newname=substr(test_name,findw(test_name,'MP')+3);
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You can use FINDW and SUBSTR

 

newname=substr(test_name,findw(test_name,'MP')+3);
--
Paige Miller
sufiya
Quartz | Level 8
Thank you this works!


SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 627 views
  • 2 likes
  • 2 in conversation