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

thank you so much for your input. it opened my door to the new world of regex, never knew it before!

Ksharp
Super User

It is depended on your criteria of Keyword.

 

data have;
input var $50.;
cards;
1545253657356_EI_1_15_CUP_A
1545253657356_EI_1_15_MUG_A
1545265347356_EI_1_15_BOWL_A
1545T432657356_EI_1_15_CUP_B
15452657356_EI_1_15_MUG_B
1545265237356_EI_1_15_BOWL_B
;

data want;
set have;
key=substr(var,findc(var,,'db')+2);
run;
changxuosu
Quartz | Level 8
it works perfect. thank you so much Ksharp..
What does the modifier 'db' mean? findc(var,,'db')+2 returns the position of the first letter of the last two words (my "key word"). How this is achieved in such a simple function?! it's like magic!
Ksharp
Super User

modifier 'db' means :

'd'  only search 0-9 number,

'b' search number from RIGHT .

changxuosu
Quartz | Level 8
wow! that's pretty smart! Learned a lot! Thanks a lot!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 19 replies
  • 2939 views
  • 11 likes
  • 7 in conversation