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
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;
If you don't mind some Perl Regular Expression:
data want;
set have;
if not prxmatch('/(ACTEMRA|AVASTIN|AVEED|BOTOX|DACOGEN)/', var);
run;
Haikuo
data want;
set have(where=(therapy not in ('ACTEMRA' 'AVASTIN' 'AVEED' 'BOTOX' 'DACOGEN')));
run;
The IN will not work if the variable value actually is "AVASTIN 10MG" or similar additional information.
That is exactly the problem
I guess I may have to stick with Find function.
Thanks for all responses
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;
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.
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.