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

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 844 views
  • 0 likes
  • 2 in conversation