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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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