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.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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