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);
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.