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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.