BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PamG
Quartz | Level 8

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use single quotes so the macro processor will ignore the string.

if prxmatch('m/KLM&F/i',varchar) >0;

 

View solution in original post

3 REPLIES 3
PamG
Quartz | Level 8

Correction: Please note that I missed putting the ending quotation marks after /i.  I cannot edit my post to make the correction.

Tom
Super User Tom
Super User

Use single quotes so the macro processor will ignore the string.

if prxmatch('m/KLM&F/i',varchar) >0;

 

PamG
Quartz | Level 8

Thanks!  

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 957 views
  • 0 likes
  • 2 in conversation