Hello,
I have been working on the following for quite some time, and I just can't seem to figure it out.
I have 2 tables -
Table 1: ingredient_1, ingredient_2 and drug_cid;
Table 2: x_drug_name, drug_concept_id, (and some others not important to this at the moment)
I want to match ingredient_1 AND ingredient_2 from Table 1 to x_drug_name in Table 2 when drug_concept_id=0. I am doing a text matching. x_drug_name might look something like this: "amLODIPine-atorvastatin 5 mg-20 mg oral tablet".
When there is a record where both ingredient_1 and ingredient_2 are present, I want to add drug_cid to the record.
Here is my code:
data TxtMatch;
length x_drug_name $ 50
ingredient_1 $50
ingredient_2 $50;
If (_n_=1) then do;
declare hash drug (dataset: 'Drugs.statincombos');
Drug.DefineKey ('ingredient_1', 'ingredient_2');
Drug.DefineData ('ingredient_1', 'ingredient_2','drug_cid');
Drug.DefineDone ();
call missing(ingredient_1, ingredient_2, drug_cid);
end;
do until (eof2) ;
set sample.de_sample2 end = eof2;
where drug_concept_id=0;
x_drug_name2=x_drug_name;
do i = 1 to 5;
ingredient_1=scan(upcase(x_drug_name),i,' -/!*#\,');
do i = 1 to 5;
ingredient_2=scan(upcase(x_drug_name2),i,' -/!*#\,');
rc = Drug.find(key: 'ingredient_1', key: 'ingredient_2');
if rc=0 then output;
End;
End;
End;
keep drug_exposure_id
drug_exposure_start_date
x_drug_name
x_drug_name2
ingredient_1
ingredient_2
drug_concept_id
drug_cid;
run;
I am not getting any errors, so I am not sure where the problem is.
Thank you for any help and guidance you may be able to provide
--SS
Thank you for the suggestion. I made the following change:
do j = 1 to 5;
ingredient_2=scan(upcase(x_drug_name2),j,' -/!*#\,');
Unfortunately, it is still not working.
Thank you! That did the trick!
I probably should have asked the question 8 hrs ago 🙂
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.