BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
appleorange
Obsidian | Level 7

I have a dataset (patients) as such:

Pat_ID     Hos     Date

A              11        1/1/2012

B              12         2/3/2012

B              13         2/3/2012

C              11         4/1/2012

C               11         4/5/2012

How do I count using proc sql such that the outcome looks something like this:

Pat_ID      Visits

A                 1

B                   1

C                    2

Since B has two visits on the same date, they are considered as only 1 visit, whereas C has 2 visits because they are on different dates.

1 ACCEPTED SOLUTION

Accepted Solutions
billfish
Quartz | Level 8

you can try:

proc sql;

select pat_id, count(distinct date) as visits

from   patients

group by pat_id;

quit;

View solution in original post

1 REPLY 1
billfish
Quartz | Level 8

you can try:

proc sql;

select pat_id, count(distinct date) as visits

from   patients

group by pat_id;

quit;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 3976 views
  • 0 likes
  • 2 in conversation