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
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.
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
I still think you do not need to read ahead. Your RegEx seems to be needlessly complex.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.