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-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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