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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2401 views
  • 11 likes
  • 7 in conversation