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


Hi I want after the last Last delimiter text should be extract and replaced _ with Space delimiter in sas 

 

data ddd;
format Have $50. Want$50.;
Have="\core\event\user_login_failed";
Want=(substr(Have,1,index(Have,"\")+(lengthn("\")-1)));
run;

 

Have="\core\event\user_login_failed";
Want=user_login_failed

replaced instead of user login failed


Thanks,

Siva

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Hi I want after the last Last delimiter text should be extract and replaced _ with Space delimiter in sas 

Assuming that you mean you want to take the last "word" from a delimited string then use the SCAN() function.

To replace characters use the TRANSLATE() function.

want=translate(scan(have,-1,'\'),' ','_');

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Hi I want after the last Last delimiter text should be extract and replaced _ with Space delimiter in sas 

Assuming that you mean you want to take the last "word" from a delimited string then use the SCAN() function.

To replace characters use the TRANSLATE() function.

want=translate(scan(have,-1,'\'),' ','_');
sivastat08
Pyrite | Level 9

Thank you very much Tom!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 3283 views
  • 0 likes
  • 2 in conversation