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?
Thanks, just figured it out. It's as simple as including not in front of prxmatch:
if not prxmatch(arguments)
https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf
I think this is what you want. Without example data, we can't know what you need.
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.
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;
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.
Thanks, just figured it out. It's as simple as including not in front of prxmatch:
if not prxmatch(arguments)
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!
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.