- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to exclude the 'SUB' and 'NCV' in the PRXMATCH command. I have the code below. I found the texts are still in the result TEMPID. Please help. Thank you.
if prxmatch ('/000|^SUB|^NCV/i',id) then TempID=id;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @ybz12003 Not sure your objective,
Assuming you are saying something like below is what you want
if id = '000' or id not in ('SUB','NCV') then tempid=id;/*assuming you want this*/
is literally equivalent to
if id not in ('SUB','NCV') then tempid=id;
which basically is equivalent to
if not prxmatch ('/SUB|NCV/i',id) then TempID=id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm not entirely sure what you want to do here. Your code matches string that contain '000' or starts with either 'sub' or 'ncv' (case insensitive).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @ybz12003 Not sure your objective,
Assuming you are saying something like below is what you want
if id = '000' or id not in ('SUB','NCV') then tempid=id;/*assuming you want this*/
is literally equivalent to
if id not in ('SUB','NCV') then tempid=id;
which basically is equivalent to
if not prxmatch ('/SUB|NCV/i',id) then TempID=id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ybz12003 wrote:
Hello,
I would like to exclude the 'SUB' and 'NCV' in the PRXMATCH command. I have the code below. I found the texts are still in the result TEMPID. Please help. Thank you.
if prxmatch ('/000|^SUB|^NCV/i',id) then TempID=id;
Please provide some sample data and then show us the desired result.
For your RegEx: Do you by any chance believe the ^ has a meaning of NOT?
^abc Here the ^ means beginning of string so strings starting with abc will match.
[^abc] Here the ^ has the meaning of NOT and string containing a, b, or c anywhere will not match
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Below is my sample dataset.
data datain;
infile datalines dsd;
input Name : $300. ;
datalines;
0001234,
SUB0001031,
NCV0001234,
CARID0001070,
;
run;
The final result I want is 0001234 and CARID0001070.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @ybz12003 Please check if this works
data datain;
infile datalines dsd;
input Name : $300. ;
datalines;
0001234,
SUB0001031,
NCV0001234,
CARID0001070,
;
run;
data want;
set datain;
where not prxmatch ('/^(SUB|NCV)/i',name);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Like this?
where NAME not in: ('SUB','NCV') and index(NAME,'000');