BookmarkSubscribeRSS Feed
avatar
Fluorite | Level 6

Hi,

I am interested to delete some drugs in a string (occuring in the middle of the string that has drug name) . I used find function like below. it works however  I have a long list of

if find (therapy, 'ACTEMRA') then delete;

if find (therapy, 'AVASTIN') then delete;

if find (therapy, 'AVEED') then delete;

if find (therapy, 'BOTOX') then delete;

if find (therapy, 'DACOGEN') then delete;

Is it possible to combine all and more drugs in one statement?

Please advise.

Thanks

6 REPLIES 6
stat_sas
Ammonite | Level 13

Something like this may help.

data want;

     set have;

  array del(5) ACTEMRA AVASTIN AVEED BOTOX DACOGEN;

  counter=0

     do i=1 to dim(del);

           if find(therapy,vname(del(i)), 'i') then counter+1;

     end;

  if counter>=1 then delete;

run;

Haikuo
Onyx | Level 15

If you don't mind some Perl Regular Expression:

data want;

     set have;

     if not prxmatch('/(ACTEMRA|AVASTIN|AVEED|BOTOX|DACOGEN)/', var);

run;

Haikuo

slchen
Lapis Lazuli | Level 10

    data want;

    set have(where=(therapy not in ('ACTEMRA' 'AVASTIN' 'AVEED' 'BOTOX' 'DACOGEN')));

    run;

ballardw
Super User

The IN will not work if the variable value actually is "AVASTIN 10MG" or similar additional information.

avatar
Fluorite | Level 6

That is exactly the problem
I guess I may have to stick with Find function.

Thanks for all responses

ballardw
Super User

A modification of

data want;

     set have;

  array del{5} $ _temporary_  ('ACTEMRA','AVASTIN','AVEED','BOTOX','DACOGEN'); /* add the values and update the number in the array reference

  counter=0;

     do i=1 to dim(del);

           if find(therapy,del(i)) then counter+1;

     end;

  if counter>=1 then delete;

  drop i counter;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1361 views
  • 1 like
  • 5 in conversation