BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lillymaginta
Lapis Lazuli | Level 10
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 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @lillymaginta,

 

Try this:

proc sql;
create table want as
select drug, count(distinct id) as frequency
from have
group by drug;
quit;

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @lillymaginta,

 

Try this:

proc sql;
create table want as
select drug, count(distinct id) as frequency
from have
group by drug;
quit;
lillymaginta
Lapis Lazuli | Level 10
Thank you FreelanceReinhard

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1169 views
  • 3 likes
  • 2 in conversation