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

Hi,  I would like to use PRXmatch to exclude the words in the argument rather than the usual include. Is there an option or modifier to do this? 

1 ACCEPTED SOLUTION

Accepted Solutions
vegan_renegade
Obsidian | Level 7

Thanks, just figured it out.  It's as simple as including not in front of prxmatch:

 

if not prxmatch(arguments)

View solution in original post

4 REPLIES 4
maguiremq
SAS Super FREQ

https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf

 

maguiremq_0-1651256583218.png

 

I think this is what you want. Without example data, we can't know what you need.

vegan_renegade
Obsidian | Level 7

I don't have data immediately available but here's my data step as an example:

 

data test1;
set test;
if prxmatch("m/word1|word2|word3/io", variable) > 0; 
run;

 

Instead including word1, word2, and word3 in output, I want to exclude those. 

Just now, I thought that if I include "then delete" after the if statement, it might do what I want.

maguiremq
SAS Super FREQ
data have;
input variable :$25.;
datalines;
word1
word2
word99
whatisaword
wordle
what
;
run;

data want;
	set have;
		if prxmatch("/[^(word1|word2|word3)]/", trim(variable)) > 0;
run;

maguiremq_0-1651258328593.png

But even then, I'm wondering if you have extra whitespace or you could literally just switch the condition (>0). I can't tell without example data.

vegan_renegade
Obsidian | Level 7

Thanks, just figured it out.  It's as simple as including not in front of prxmatch:

 

if not prxmatch(arguments)

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 4 replies
  • 1509 views
  • 0 likes
  • 2 in conversation