BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello,

 

The prxmatch program below is searching the created macro list as 'CAR|IL|VN|KK'.   However, I would like the search be more restricted.   Instead of containing the ''CAR|IL|VN|KK'' string in the text,  I like to match 100% these two letters.   Please advice how to change this prxmatch codes.  Thank you.

 

if prxmatch ("/&Jurisdiction_list./i",id) then TempID=id;

The following sample data set is

data datain;
      infile datalines dsd;
  input ID : $300. ;
datalines;
	CAR ID  MA,
	ILH,
	PAUL  VN,
	KKK GGGG,
	Card ID BMA,
	Care ID FMA,
;

run;

 

The final result I am looking for is only at the 1st and 3rd row.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
%let Jurisdiction_list=CAR|IL|VN|KK;
data datain;
      infile datalines dsd;
  input ID : $300. ;
datalines;
	CAR ID  MA,
	ILH,
	PAUL  VN,
	KKK GGGG,
	Card ID BMA,
	Care ID FMA,
;

run;
data want;
set datain;
if prxmatch ("/\b(&Jurisdiction_list)\b/i",id) then TempID=id;
run;

ID TempID
CAR ID MA CAR ID MA
ILH  
PAUL VN PAUL VN
KKK GGGG  
Card ID BMA  
Care ID FMA  

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20
%let Jurisdiction_list=CAR|IL|VN|KK;
data datain;
      infile datalines dsd;
  input ID : $300. ;
datalines;
	CAR ID  MA,
	ILH,
	PAUL  VN,
	KKK GGGG,
	Card ID BMA,
	Care ID FMA,
;

run;
data want;
set datain;
if prxmatch ("/\b(&Jurisdiction_list)\b/i",id) then TempID=id;
run;

ID TempID
CAR ID MA CAR ID MA
ILH  
PAUL VN PAUL VN
KKK GGGG  
Card ID BMA  
Care ID FMA  
ybz12003
Rhodochrosite | Level 12

What is the '\b' for?  Why need to one at the front and one at the end? 

 

novinosrin
Tourmaline | Level 20

\b metacharacter is known as word boundary. When you mentioned "absolute" match of a word, my thought went straight to wrap the search string to make it a word boundary with \b

ybz12003
Rhodochrosite | Level 12

Thank you.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 580 views
  • 0 likes
  • 2 in conversation