How do I go about using PRXMATCH to search for a string that contains ampersand ? SAS is assuming that it is a macro variable.
data have;
input varchar $;
datalines;
ABCDEF
GHI
KLM
KLM&F
KLM&FG
;
run;
data want;set have;
if prxmatch("m/KLM&F/i,varchar) >0; *gives an error Macro variable F not resolved;
run;
Use single quotes so the macro processor will ignore the string.
if prxmatch('m/KLM&F/i',varchar) >0;
Correction: Please note that I missed putting the ending quotation marks after /i. I cannot edit my post to make the correction.
Use single quotes so the macro processor will ignore the string.
if prxmatch('m/KLM&F/i',varchar) >0;
Thanks!
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.