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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.