BookmarkSubscribeRSS Feed
aaaaa34
Calcite | Level 5

Hi,

 

I would like to make an if condition like if PRXMATCH(..., var1)>0 then delete. I would like to remove all cases in which I have:

  • 0,00dd
  • 454dd
  • 0,234dd

Thanks in advance!

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Do you want to delete the observations where any of those three strings occur or do you want to delete the 'dd' part of the posted strings?

aaaaa34
Calcite | Level 5
I want to delete the observations where these three strings occur.
PeterClemmensen
Tourmaline | Level 20

Like this?

 

data have;
input string $20.;
datalines;
abc0,00ddabc
abcabc
defdef
abcdef454dd
0,234ddabcdef
;

data want;
   set have;
   if not prxmatch('/0,00dd|454dd|0,234dd/', string);
run;
aaaaa34
Calcite | Level 5

What if I have different numbers before dd? I wrote these numbers with dd only like an example. I want remove all cases in which dd is after numbers.

PeterClemmensen
Tourmaline | Level 20

Ah ok. Do this. This looks for patterns where the string 'dd' is after at least 1 digit.

 

data have;
input string $20.;
datalines;
abc0,00ddabc
abcabc
defdef
abcdef454dd
0,234ddabcdef
;

data want;
   set have;
   if not prxmatch('/\d+dd/', string);
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 800 views
  • 0 likes
  • 2 in conversation