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 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.