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_NAME | NAME |
MP KONSTANTINE ABCDE | |
WNP BM OPS TEST MP CIGI FANNING | BM O |
MP DAN BkENTHER | |
ERA MONTREAL TEST MP MARIA PUBRANTI | MARIA PUBRANTI |
MP MARIA PUBRANTI | |
MP BRUCE WAYNE | |
MYABCD DIG CHAN TEST MP ABCDE DADOUN | ABCDE DADOUN |
MP JENNIFER NOSNIKOF | OSNIKOF |
MP STEVE PETERS | E 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 |
You can use FINDW and SUBSTR
newname=substr(test_name,findw(test_name,'MP')+3);
You can use FINDW and SUBSTR
newname=substr(test_name,findw(test_name,'MP')+3);
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 25. Read more here about why you should contribute and what is in it for you!
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.