id drug v_date
1 11 01/02/2004
1 11 03/03/2005
1 11 8/3/2005
1 22 5/4/2005
1 22 6/6/2005
Hi All,
I have something similar with the above database. Multiple drugs per id and the same drug can have more than one v_date. My question I want to find the number of patients who obtained at least one drug (for example at least 1 of drug number 11) . So if I have 10 patient who had at least one of drug (no 11) in different v_date, I want to obtain an output that state: drug 11 frequency= 10, and so on
Hi @lillymaginta,
Try this:
proc sql;
create table want as
select drug, count(distinct id) as frequency
from have
group by drug;
quit;
Hi @lillymaginta,
Try this:
proc sql;
create table want as
select drug, count(distinct id) as frequency
from have
group by drug;
quit;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.