BookmarkSubscribeRSS Feed
ybz12003
Rhodochrosite | Level 12

Hello:

 

I have the following prxmatch codes. 

 

else if prxmatch("m/(?=.*?if_audiol)/i", &var) > 0 then found=18;

else if prxmatch("m/(?=.*?if_audiol_dt)/i", &var) > 0 then found=19;

else if prxmatch("m/(?=.*?if_audiol_res)/i", &var) > 0 then found=20;

else if prxmatch("m/(?=.*?if_audiol_res_sp)/i", &var) > 0 then found=21;

else if prxmatch("m/(?=.*?mhh_exp_ustrv)/i", &var) > 0 then found=223;

else if prxmatch("m/(?=.*?mhh_exp_ustrv_en)/i", &var) > 0 then found=224;

else if prxmatch("m/(?=.*?mhh_exp_ustrv_here)(?=.*?yes)/i", &var) > 0 then found=225;

else found=0;

run;

 

 

I found out all of the follow rows have been assigned to 18 and 223, how to differentiate the following conditions with the correct numbers:

 

if_audiol_1                         18

if_audiol_2                         18

if_audiol_dt_1                      19

if_audiol_dt_2                      19

if_audiol_dt_3                      19

if_audiol_res_1                     20

if_audiol_res_2                     20

if_audiol_res_3                     20

if_audiol_res_4                     20

if_audiol_res_sp_1                  21

if_audiol_res_sp_2                  21

mhh_exp_ustrv                       223

mhh_exp_ustrv_en1                   224

mhh_exp_ustrv_here1_yes             225

 

 

 

 

 

3 REPLIES 3
Reeza
Super User

Change the order of your IF/ELSE IF to have the most detailed first down to the most generic. Your current system has it backwards.

Patrick
Opal | Level 21

@ybz12003

Should your strings like if_audiol be "words" and not just sub-strings then you could also use the \b syntax to avoid matches with sub-strings and not whole words. ->  \bif_audiol\b

ChrisNZ
Tourmaline | Level 20

I still think you do not need to read ahead. Your RegEx seems to be needlessly complex.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 394 views
  • 1 like
  • 4 in conversation