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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.