- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, just figured it out. It's as simple as including not in front of prxmatch:
if not prxmatch(arguments)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, just figured it out. It's as simple as including not in front of prxmatch:
if not prxmatch(arguments)