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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.