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);
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.